Hey Im using this script to check/validate the fields in my form and I was wondering how to make it dispay all the errors at once. Say the person leaves all the fields empty, and alert box will pop-up only telling them to fill in the first field. And it just keeps going in order, one at a time, until all the fields are filled in/valid, how can I make it to display all the errors at one time?
[CODE]
<script type=”text/javascript”>
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value==””)
{alert(alerttxt);return false}
else {return true}
}
}
function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf(“@”)
dotpos=value.lastIndexOf(“.”)
if (apos<1||dotpos-apos<2)
{alert(alerttxt);return false}
else {return true}
}
}
function validate_form(thisform)
{
with (thisform)
{
if (validate_required(fname,”Please enter your first name.”)==false)
{fname.focus();return false}
if (validate_required(email,”Please enter your e-mail address.”)==false)
{email.focus();return false}
if (validate_email(email,”Not a valid e-mail address!”)==false)
{email.focus();return false}
if (validate_required(message,”Please enter your message.”)==false)
{message.focus();return false}
}
}
</script>