Number Validation Script

This javascript will help you to validate the textbox in a form. This java script function helps you to check whether the given value in the textbox is number or integer value.


  • You can validate the textbox with an integer value.
  • You can validate form using this javascript.
  • Just copy the given free javascript code and use it.


Enter value:


Javascript Code

<!-- Script by -->
/* Created on : Dec 1,2007 Javascript for validating a rounded integer value.
This script validates the given input and returns true or false.
You have to just call the function with the input as argument.
Eg:var d = isInteger(3); returns true;var e = isInteger(4.4); returns false;*/
<script type="text/javascript">
function isInteger(s)
var i;s = s.toString();
for (i = 0; i < s.length; i++)
var c = s.charAt(i);
if (isNaN(c))
alert("Given value is not a number");return false;
}return true;}</script>
<!-- Script by -->


<!-- Script by -->
<form name=test>
<input type=text name=en onKeyup="isInteger(this.value)">
<input type=button name=cc value="Check" >
<!-- Script by -->

  • Release Date - 01-12-2007
  • Get free version without ©copyright link for just $10/-
  • For customization of this script or any script development, mail to


  • Here we have explained with a form
  • Creating a form by copying the html code to the
     <body> tag 
    <form name=test>
    <input type=text name=en onKeyup="isInteger(this.value)">
    <input type=button name=cc value="Check">
  • Copy the javascript code into the
     <head> tag 
    of your page.
  • If user enters value in the textbox, the function "isInteger(this.value)" is called to check whether the entered value is number. If given value is number, textbox will accept it orelse an alert message will appear.


Related Scripts

Free Javascript Scripts

Ask Questions

Ask Question