Last active
August 15, 2018 11:15
-
-
Save omernaci/3dfa6c2fcaa6b41fb2aa9531cfdc9b47 to your computer and use it in GitHub Desktop.
JQuery Number Input First Character Disable Zero
This file contains 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
... | |
<input onfocus="disableFirstCharZero('inputId')"></input> | |
... | |
function disableFirstCharZero(elementId) { | |
$ ('#' + elementId).on( 'input propertychange paste', function(e) { | |
var reg = /^0+/gi; | |
if ( this.value.match(reg) ) { | |
this.value = this.value.replace(reg, ''); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment