Last active
May 3, 2024 19:09
-
-
Save vladimirlukyanov/a990efb823f7522db6ee8823861b17c1 to your computer and use it in GitHub Desktop.
Listen for input change programmatically | Vanilla JS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
let event = new Event('change'); | |
let inputBox = document.querySelector("#shipping_postcode"); | |
const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(inputBox), 'value'); | |
Object.defineProperty(inputBox, 'value', { | |
set: function(t) { | |
if(t === '') return; | |
return descriptor.set.apply(this, arguments); | |
}, | |
get: function() { | |
return descriptor.get.apply(this); | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment