I created a form which is working fine, but I need some fields to be validated. Below is the code I have - I paste the code in the validation area - tested the form but the validation is not working. Can someone please look at the code and tell me how to get it working. Thanks in advance.
- Code: Select all
function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2)
{alert(alerttxt);return false}
}
}
function checkForm(KSP)
{
/* CONTACT */
if(KSP.Contact_Name.value == "") {
alert("Please enter a contact name!");
return false;
}
/* COMPANY */
if(KSP.Company_Name.value == "") {
alert("Please enter your school or company name!");
return false;
}
/* MAIL */
with (KSP)
{
if (validate_Email(email,"Please enter an email address!")==false)
{email.focus();return false}
}
/* TELEPHONE */
if(KSP.Phone.value == "") {
alert("Please enter your telephone number!");
return false;
}
/* Ovo se izvršava nakon svih provjera! */
return true;
}
