Created
August 4, 2018 16:31
-
-
Save giansalex/5e0706404fcba2956cfdb29b15057d8f to your computer and use it in GitHub Desktop.
HTML Input only Numbers - Jquery
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
<!DOCTYPE html> | |
<html> | |
<body> | |
<input type="text" sb-numeric> | |
<input type="text"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | |
<script> | |
$(function () { | |
$(document).on("input", "input[sb-numeric]", function() { | |
this.value = this.value.replace(/\D/g,''); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment