function isValidEmail(str) { var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1){ alert("Invalid E-mail ID") return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ alert("Invalid E-mail ID") return false } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ alert("Invalid E-mail ID") return false } if (str.indexOf(at,(lat+1))!=-1){ alert("Invalid E-mail ID") return false } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ alert("Invalid E-mail ID") return false } if (str.indexOf(dot,(lat+2))==-1){ alert("Invalid E-mail ID") return false } if (str.indexOf(" ")!=-1){ alert("Invalid E-mail ID") return false } return true } function IsNumeric(sText) { var ValidChars = "0123456789"; var IsNumber=true; var Char; for (i = 0; i < sText.length && IsNumber == true; i++) { Char = sText.charAt(i); if (ValidChars.indexOf(Char) == -1) { IsNumber = false; } } return IsNumber; } function IsEmptyOption(aTextField) { if ( aTextField.selectedIndex == 0 ) { alert('Fill all required fields.'); return true; } } function IsEmpty(aTextField) { if ((aTextField.value.length==0) || (aTextField.value==null)) { alert('Fill all required fields.'); return true; } else { return false; } } function thesame(aTextField, bTextField) { if (aTextField.value==bTextField.value) { return true; } else { return false; } } function ValidateForm(form) { if(IsEmptyOption(form.group)) { alert('You have not choosen a group from frop down list') form.group.focus(); return false; } if(IsEmpty(form.fname)) { alert('You have not entered a first name') form.fname.focus(); return false; } if(IsEmpty(form.lname)) { alert('You have not entered a last name') form.lname.focus(); return false; } if(IsEmpty(form.city_new)) { alert('You have not entered a City') form.city_new.focus(); return false; } if(IsEmpty(form.state_new)) { alert('You have not entered a State') form.state_new.focus(); return false; } if(IsEmpty(form.phonenumber_new)) { alert('You have not entered a Phone Number') form.phonenumber_new.focus(); return false; } if(IsEmpty(form.email_new)) { alert('You have not entered an Email Address') form.email_new.focus(); return false; } if(IsEmpty(form.email2_new)) { alert('You have not entered an Email Address') form.email2_new.focus(); return false; } if(!isValidEmail(form.email_new.value)) { alert('You have not entered valid email') form.email_new.focus(); return false; } if(!thesame(form.email_new, form.email2_new)) { alert('Please make sure both email addresses are the same') return false; } if (!IsNumeric(form.phonenumber_new.value)) { alert('Please enter only numbers in the Primary phone number field') form.phonenumber_new.focus(); return false; } return true; }