//alert ("went in to validation"); var validate; function validate(obj) { //define objects to validate var allElements = obj.elements; var coCount = 0; var errors = ""; for( i=0 ; i\,\;\:\\\/\"\[\]]/; if (oEmail.match(illegalChars)) { errors += "Your email contains illegal characters\n"; } else if ( (ndxDot < 0) ) //check for a '.' sign { errors += "->Your email lacks '.'\n\tThe format is 'you@domain.com'"; } else if ( (ndxAt < 0) ) //check for an '@' sign { errors += "->Your email lacks an '@'\n\tThe format is 'you@domain.com'"; } else if (ndxDot2 - 3 <= ndxAt) { errors += "->You may be missing Your email's domain name\n\tThe format is 'you@domain.com'"; } } } ////MAILNGLIST CHECKS //CHECK CONTACT DIAL CODE NUMBER NOT EMPTY else if (allElements[i].type=="text" && allElements[i].name == "contact-area1") { var oFullName = allElements[i].value; if ( oFullName.length <= 0 ) { errors += "-> Dialing code is a mandatory field\n"; } } //CHECK CONTACT NUMBER1 NOT EMPTY else if (allElements[i].type=="text" && allElements[i].name == "contact-area2") { var oFullName = allElements[i].value; if ( oFullName.length <= 0 ) { errors += "-> Area code is a mandatory field\n"; } } //CHECK CONTACT NUMBER2 NOT EMPTY else if (allElements[i].type=="text" && allElements[i].name == "contact-number") { var oFullName = allElements[i].value; if ( oFullName.length <= 0 ) { errors += "-> Contact number is mandatory field\n"; } } //CHECK FRIENDS FULLNAME NOT EMPTY if (allElements[i].type=="text" && allElements[i].name == "friendsname") { var oFullName = allElements[i].value; if ( oFullName.length <= 0 ) { errors += "-> The friend's name is a mandatory field, please enter your friend's name\n"; } } //CHECK FRIENDS EMAIL ADDRESS NOT EMPTY AND VALID else if (allElements[i].type == "text" && allElements[i].name == "friendsemail") { var oEmail = allElements[i].value; var chkDot = true; var result = false; var ndxAt = ndxDot = 0; var ndxAt = ndxDot = 0; if (oEmail.length <= 0 ) { errors += "-> The friend's email is a mandatory field, please enter your friend's email \n"; } else //not empty start email address validation { ndxAt = oEmail.indexOf("@"); ndxDot = oEmail.indexOf("."); ndxDot2 = oEmail.lastIndexOf("."); var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/; if (oEmail.match(illegalChars)) { errors += "The friend's email contains illegal characters\n"; } else if ( (ndxDot < 0) ) //check for a '.' sign { errors += "->The friend's email Address lacks '.'\n\tThe format is 'you@domain.com'"; } else if ( (ndxAt < 0) ) //check for an '@' sign { errors += "->The friend's email Address lacks an '@'\n\tThe format is 'you@domain.com'"; } else if (ndxDot2 - 3 <= ndxAt) { errors += "->You may be missing your friend's domain name\n\tThe format is 'you@domain.com'"; } } } //COMMENTS if (allElements[i].name == "comments") { var ocomments = allElements[i].value; if ( ocomments.length <= 0 ) { errors += "-> Your comments is a mandatory field\n"; } } //CHECK CODE NOT EMPTY if (allElements[i].type=="text" && allElements[i].name == "code") { var oFullName = allElements[i].value; if ( oFullName.length <= 0 ) { errors += "-> Code is a mandatory field, please retype the code from the image below\n"; } } } if (coCount == 2) { errors += "-> Please fill in the neccesary country and area code in the Contact Number\n"; } if(errors) { alert("The following errors were found\n" + errors); errors = ""; returnVal = false; } else { returnVal = true; } return returnVal; }