Validation Script

Post any questions you may have here

Validation Script

Postby LikeStuff on Thu May 08, 2008 3:29 pm

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.
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;
}
LikeStuff
Fresh Boarder
 
Posts: 18
Joined: Thu May 08, 2008 3:19 pm

Re:Validation Script

Postby admin on Sat May 10, 2008 7:20 pm

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
ChronoForms/ChronoConnectivity/ChronoComments Developer Thanks for using our components!
If you have any problems with any extension please tell us.
If you like any of our extensions please post a review at Joomla.org
Want users to submit their content to your website ? try Submit Story
Want to list/edit/delete your data ? try ChronoConnectivity
Want to have stylish AJAX comments ? try ChronoComments
User avatar
admin
Platinum Boarder
 
Posts: 3235
Joined: Mon Aug 14, 2006 5:29 am

Re:Validation Script

Postby GreyHead on Sat May 10, 2008 10:29 pm

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
Bob Janes
info at greyhead.net
ChronoForms Support If you like ChronoForms please vote or post a review at Joomla.org
User avatar
GreyHead
Platinum Boarder
 
Posts: 3437
Joined: Tue May 29, 2007 10:15 pm
Location: Brittany

Re:Validation Script

Postby LikeStuff on Wed May 14, 2008 3:58 pm

Now I have 2 options. Didn't notice the validation in the backend. Thanks guys.
LikeStuff
Fresh Boarder
 
Posts: 18
Joined: Thu May 08, 2008 3:19 pm


Return to ChronoForms Questions & Answers

Who is online

Users browsing this forum: Google [Bot], koolie, MSN [Bot], MSNbot Media, revive, Yahoo [Bot] and 5 guests