﻿function ContactUsFormSubmit() {
    var flag = true;
    $(".CheckField").each(function(i) {
        if (typeof $(this).attr("regex") != 'undefined') {
            var regex = new RegExp($(this).attr("regex"));
            if ($(this).attr("class").indexOf("required") != -1) {
                if (!(regex).test($(this).val())) {
                    flag = false;
                }
            }
            else // IF IT NOT A REQUIRED FIELD
            {
                if ($(this).val().length > 0) {
                    if (!(regex).test($(this).val())) {
                        flag = false;
                    }
                }
            }
        }
    })
    if (flag) {
        document.ContactUsForm.submit();

    }
    else {
    $(".ErrMsg").css("display", "block");
     }
}

