Validation Script

LikeStuff 08 May, 2008
Please bear with me on this as I have no idea regarding javascript.

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.
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;
}
Max_admin 10 May, 2008
Hi,

The form name is not KSP, open your form page source and see the form name, it should be : ChronoContact_KSP if you have it named as KSP in Chronoforms admin area

Cheers

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
GreyHead 10 May, 2008
Hi LikeStuff,

You can do most of this with the built in validation in ChronoForms. The messages won't be quite so friendly but otherwise you'll get the same functionality (better for the email) for less effort.

Bob
LikeStuff 14 May, 2008
Now I have 2 options. Didn't notice the validation in the backend. Thanks guys.
This topic is locked and no more replies can be posted.