Pls help me out !!!
I have two text fields in a form that i need to validate to be non-empty and numeric(0-9) only.I have done the non-empty validation, but not able to do the numeric one.
Here is my code-
Code:
<script language="JavaScript">
function onlyNumbers()
{
valid=true;
if (document.form1.consumerno.value == "")
{
alert ( "Please fill in your consumer no.." );
valid = false;
}
if (document.form1.mobileno.value == "")
{
alert ( "Please fill in your mobile no.." );
valid = false;
}
if (document.form1.consumerno.value == "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz")
{
alert ( "Numbers only" );
valid = false;
}
if (document.form1.mobileno.value == "ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz")
{
alert ( "Numbers only" );
valid = false;
}
return valid;
}
</script>
And the form part as-
Code:
<form name="form1" action="success.html" method="post" onsubmit="return onlyNumbers();">
<br><br>
<center><b>Consumer Number:
<input type="text" name="consumerno">
</b></center>
<br><br>
<center><b>Mobile Number:
<input type="text" name="mobileno" >
</b></center>
<br><br><br>
<center>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Reset"></center>
Can anybody help me out plssssssssss....!!!