Allow Only Numbers in Textbox
Javascript code allows only the numbers or numeric values to enter into the textbox.
Features
- Code accepts numerical value and restricts other values on every key press.
- Performs validation for numbers entered in the textbox.
- Simple, responsive and easy to integrate.
Preview
Downloads
Script Code<!-- Script by hscripts.com --> <!-- More scripts @www.hscripts.com -->
<script type="text/javascript">function checnum(as){var dd = as.value;
if(isNaN(dd))
{dd = dd.substring(0,(dd.length-1));as.value = dd;}
}
</script>
- Release Date - 29-05-2015
- Get free version without ©copyright link for just $10/-
- For customization of this script or any script development, mail to support@hscripts.com
Usage
- Copy and paste the javascript function inside the <head> tag of your HTML page.
- Call "checnum()" function in the onkeyup event of your text box.
ie., onkeyup="checnum(this)".
- Here, the function "checnum()" is used to allow only numbers in the textbox.
License
Related Scripts