
i have put this code for only entering integer value in text box however error occured.. if(document.formname.textbox1.value!=="") { var rn,i;
rn=document.formname.textbox1.value;
for(i=0i

Here is a javascript code that validate s the number.
<html>
<script>
function validate(){
if(document.form.num.value == ""){
alert("Please enter number!" );
document.form.num.focus();
return false;
}
var con=document.form.num.value;
var ex = new RegExp(/^\d+$/);
var t=ex.test(con);
if(!t){
alert("Enter only Number .");
document.form.num.focus();
return false;
}
}
</script>
<form name="form" method="post" onsubmit="return validate();">
<pre>
Enter Number: <input type="text" name="num">
<input type="submit" value="Check">
</pre>
</form>
</html>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.