The above code is working fine. If i added another form. The code might looks like below.Code:<script> function validateForm() { var x=document.forms["myForm"]["name"].value; if (x==null || x=="") { alert("First name must be filled out"); return false; } } </script> <form name="myForm" action="<?php print $PHP_SELF ?>" onsubmit="return validateForm()" method="post"> Input name : <input type="text" name="name"><br><br> <input type="submit" name="students" value="addnow">
It is not working for the validation. Can anyone pls help ?Code:<form name="form" action="<?php print $PHP_SELF ?>" method="post"> <input type="text" name="time"> <input type="submit" name="date" value="insert"> <script> function validateForm() { var x=document.forms["myForm"]["name"].value; if (x==null || x=="") { alert("First name must be filled out"); return false; } } </script> <form name="myForm" action="<?php print $PHP_SELF ?>" onsubmit="return validateForm()" method="post"> Input name : <input type="text" name="name"><br><br> <input type="submit" name="students" value="addnow">


Reply With Quote
Bookmarks