Created
September 18, 2013 12:11
-
-
Save ajitam/6608282 to your computer and use it in GitHub Desktop.
Add class "js-number-only" to input to limit input to numbers only
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
$(".js-number-only").bind('change keyup input', function() { | |
var value = $(this).val(); | |
value = value.replace(/[^0-9]+/g, ''); | |
$(this).val(value); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment