I'm using the folowing code for validation:
<script type="text/javascript">
function validate_email(email,alerttxt)
{
with (email)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2)
{alert(alerttxt);return false}
else {return true}
}
}
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{alert(alerttxt);return false}
else {return true}
}
}
function validate_form(thisform)
{
with (thisform)
{
if (validate_required(name,"Name is required!")==false)
{name.focus();return false}
}
with (thisform)
{
if (validate_required(phone,"Phone number is required!")==false)
{phone.focus();return false}
}
with (thisform)
{
if (validate_email(email,"Please enter a valid e-mail address!")==false)
{email.focus();return false}
}
with (thisform)
{
if (validate_required(comments,"Please write your comments!")==false)
{comments.focus();return false}
}
}
</script>
when using a submit button validation works fie. When submiting the form with a text link the validation is not working. Here's my text link:
<a href="#" onclick="javascript:document.form1.submit()">send</a>
i'm using the following to call the validation script:
<form id="form1" name="form1" method="post" onsubmit="return validate_form(this)" action="contact.php">
Can anybody help me with this?