Created
August 17, 2012 19:42
-
-
Save ekka21/3381924 to your computer and use it in GitHub Desktop.
Javascript: allow only digits zipcode zip
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
function isNumberKey(evt) | |
{ | |
var charCode = (evt.which) ? evt.which : event.keyCode | |
if (charCode > 31 && (charCode < 48 || charCode > 57)) | |
return false; | |
return true; | |
} | |
<input type="text" onkeypress="return isNumberKey(event)" maxlength="5" placeholder="Search by Zip" id="addressInput"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment