Last active
December 17, 2015 06:08
-
-
Save allusis/1423a044e311da5a0ef1 to your computer and use it in GitHub Desktop.
Apex - input number only
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> | |
function isNumberOnly(evt) { | |
var charCode = (evt.which) ? evt.which : evt.keyCode; | |
//console.log(charCode); | |
if(charCode == 110 || charCode == 190) { | |
return true; | |
} | |
if (charCode != 46 && charCode > 31 | |
&& (charCode < 48 || charCode > 57 && charCode < 96 || charCode > 105)) { | |
evt.preventDefault(); | |
return false; | |
} | |
return true; | |
} | |
</script> | |
<apex:inputText onKeyDown="isNumberOnly(event);" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment