I am doing length validation but it's not working. For this I am using onBlur event but it is not working. Please help me how to do it. I think it is not firing onBlur event. My code is following - <body> <script language="javascript1.2"> function verify(form) { if(form.my.value=="") { alert("please fill"); document.form.my.focus(); return(false); } } function checklen(form) { val = form.my.value; len=val.length; alert("writwe value"); if(len>10) { alert("value exceeds 10 character"); form.my.value=""; form.my.focus(); } } </script> <form name="form" method="post" onSubmit="return verify(this)" action="validation2.php"> <p> <input type="text" name="my" onBlur="checklen(this)"> </p> <p> <input type="text" name="my2"> </p> <p> <input type="submit" name="Submit" value="Submit" > </p> </form> </body>
Hi Kharearch. Rename your form to something different (name="myform" instead of name="form" for example), change it in your javascript code correspondingly and that should resolve your issue.