Mega Code Archive

 
Categories / JavaScript Tutorial / Form
 

Return false in form button click event

< html> <head> <title>A Simple Page</title> <script language="JavaScript"> <!-- function chkForm() {     if (form1.inp1.value == "")     {         alert("Please fill in the text box");         form1.inp1.focus();         return false;     } } //  --> </script> </head> <body> <form name="form1" method="POST" action=""> <P><input type="text" name="inp1"> <input type="submit" value="Submit" onClick="return chkForm()"> <input type="reset" value="Reset"></p> </form> </body> </html>