﻿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;
                    $(this).addClass("RedBorder");
                }
                else $(this).removeClass("RedBorder");
            }
            else // IF IT NOT A REQUIRED FIELD
            {
                if ($(this).val().length > 0) {
                    if (!(regex).test($(this).val())) {
                        flag = false;
                        $(this).addClass("RedBorder");
                    }
                    else $(this).removeClass("RedBorder");
                }
            }
        }
    })
    if (flag) {
        $("#ContactUsSendBtn").attr("onclick", "");
        document.ContactUsForm.submit();
        
    }
}
$(document).ready(function(){
    $(".InputNum").keypress(function(e) {
        if (e.whice != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) return false;
    })
})

