In my form validation is applied for informing Invalid data entered in the field before submit the form instantly at the time of mistake. After throwing the correct instant alert message of mistake , the Invalid data entered by user get selected but does not Erased and invalid data remain selected after this. please suggest me what should done so that the invalid data entered should be Erased completely after giving Error alert message of "Invalide data" . & the text field get empty for entering new valid data in it. small code of my form is shown below:- <html> <head> <script type="text/javascript"> function validate_required(form2) { if (form2.name.value=="") { alert("Please enter the Full Name"); document.form2.name.focus(); return false; } return true; } function checkName() { if (!isNaN(document.getElementById('name').value)) { alert("Invalid numeric value entered! Please enter the Valid Name"); document.form2.name.focus(); return false; } return true; } </script> </head> <body> <form name="form2" id="form2" onsubmit="return validate_required(this)" action="infosubmit2.php" method="post" > Name : <input type="text" name="name" id="name" onkeyup="checkName()" size="40" /> </body> </html> Code (markup): Thanks & Regards.
Hi MSK7, just add this before calling the focus() in both functions. That tells that the value of the form field called 'name' should be set to '' (empty string). document.form2.name.value = '';
Hello sir, Thanks for your precious Suggession for this problem. Your guidance solved my problem . Hope to get your precious suggessions & guidance in future also. Thanks & Regards.