Java-script is a powerful technique to check certain condition on client-side itself before submitting form to check at server-side,so that time will be saved.
Here we are going to know how to check a value whether it is number or not and no's not more than 6 using javascript.
For ex.You get the value from simple form.
Quote:<form name="f">
<input type="text" name="zip" onblur="return checkzip()"/>
</form>
Write this code before head section
<script type="text/javascript">
function checkzip()
{var StringVar=new String(document.f.zip.value);
var x=StringVar.length;
if(x==6&&!isNaN(document.f.zip.value))
{
return true;
}
else
{
alert("zipcode must be 6 digits") return false;
}
}
</script>
Try this code and do comment we will be happy to hear from you.
Happy coding