﻿function checkForm() {
    var strErrorMsg = "";
    if (typeof document.Form1 != 'undefined') {
        //remove1
        //FirstName
        if (document.Form1.firstname) {
            if (document.Form1.firstname.value == "")
                strErrorMsg += "Please enter  first name\n";
        }
        //LastName
        if (document.Form1.lastname) {
            if (document.Form1.lastname.value == "")
                strErrorMsg += "Please enter  last name\n";
        }
        //Address1
        if (document.Form1.address1) {
            if (document.Form1.address1.value == "")
                strErrorMsg += "Please enter  address\n";
        }
        //Email
        if (document.Form1.email) {
            if (checkemail(document.Form1.email.value) != true) {
                strErrorMsg += "Please enter a valid Email Address\n";
            } 
        }
        //City
        if (document.Form1.city) {
            if (document.Form1.city.value == "")
                strErrorMsg += "Please enter  city\n";
        }
        //State
        if (document.Form1.state) {
            if (document.Form1.state.value == "")
                strErrorMsg += "Please enter  state\n";
        }
        //ZipPost
        if (document.Form1.zip) {
            if (document.Form1.zip.value == "")
                strErrorMsg += "Please enter  zip\n";
            else {
                if (isNaN(document.Form1.zip.value))
                    strErrorMsg += "Please enter Numerical Values Only for Zip Code\n";
            }
        }
        //PhoneCode
        if (document.Form1.phonecode) {
            if (document.Form1.phonecode.value == "")
                strErrorMsg += "Please enter  phone area code \n";
            else {

                if (isNaN(document.Form1.phonecode.value))
                    strErrorMsg += "Please enter Numerical Values Only for home phone code \n";

            }
        }
        //PhonePrefix
        if (document.Form1.phoneprefix) {
            if (document.Form1.phoneprefix.value == "")
                strErrorMsg += "Please enter  phone prefix \n";
            else {

                if (isNaN(document.Form1.phoneprefix.value))
                    strErrorMsg += "Please enter Numerical Values Only for home phone prefix \n";

            }
        }
        //PhoneSuffix 
        if (document.Form1.phonesuffix) {
            if (document.Form1.phonesuffix.value == "")
                strErrorMsg += "Please enter  phone suffix \n";
            else {

                if (isNaN(document.Form1.phonesuffix.value))
                    strErrorMsg += "Please enter Numerical Values Only for home phone suffix \n";
            } 
        }
        //DobMonth
        if (document.Form1.dobmonth) {
            if (document.Form1.dobmonth.value == "")
                strErrorMsg += "Please enter  birth month\n";
        }
        //DobDay
        if (document.Form1.dobday) {
            if (document.Form1.dobday.value == "")
                strErrorMsg += "Please enter  birth day\n";
        }
        //DobYear
        if (document.Form1.dobyear) {
            if (document.Form1.dobyear.value == "")
                strErrorMsg += "Please enter  birth year\n";
        }
        //Gender
        if (document.Form1.gender) {
            if (!document.Form1.gender[0].checked && !document.Form1.gender[1].checked)
                strErrorMsg += "Please select Gender\n";
        }
        //remove2 
        
    }

    if (strErrorMsg != "") {
        alert(strErrorMsg);
        return false;
    }
    else {
        return true;
    }
}

function checkemail(email){
    var str=email
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
    if (filter.test(str))
        return true
    else{
        return false;
    }
}