i am making a user registration form with validation.thats my simple form field.
<tr>
First Name:
<input type="text" name="fname" id="letters" /><span id="error" style="color:red;"></span>
<tr>
<tr>
Last Name:
<input type="text" name="lname" id="letters1" /><span id="error1" style="color:red;"></span>
</tr>
<input type="submit" value="submit" name="submit" />
i am using a validation function on submit onsubmit=”return ValidateForm();
in the validation function
function ValidateForm(){
if (document.reg.fname.value=="" || !document.reg.fname.value.match(/[^\s]/))
{
document.getElementById("error").innerHTML = "enter first Name"
return false;
}
else
{
document.getElementById("error").innerHTML = '';
}
if (document.reg.lname.value=="" || !document.reg.lname.value.match(/[^\s]/))
{
document.getElementById("error1").innerHTML = "enter last Name"
return false;
}
else{
document.getElementById("error1").innerHTML = '';
}
but for try when i submit the button..the ERROR MESSAGE shows only with first input box, and when i fill the first box then submit ..this time the error MESSAGE shows with Second text box. i am wanted to show all error message with same time.
Remove the return false between the tests
For a quick fix to your code I would do something like this
DEMO HERE
and have