PDA

View Full Version : Validation problem



MSK7
02-26-2009, 12:39 PM
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 must be Erased completely

after giving Error alert message of "Invalide data entered" .

& 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>



Thanks & Regards.