﻿function Validation() {
    if ((document.form1.txtname.value == '') && (document.form1.txtemail.value == '') && (document.form1.txtmessage.value == '') && (document.form1.txtphoneno.value == '')) {
        alert("First Fill All Details...");
        document.form1.txtname.focus();
        return false;
    }
    else {
        if (document.form1.txtname.value == '') {
            alert("Name Field can not be blank");
            document.form1.txtname.focus();
            return false;
        }

        var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
        var emailid = document.form1.txtemail.value;
        var matcharray = emailid.match(emailPat);
        if (matcharray == null) {
            alert("Email Address seems incorrect. Please Try Again.");
            document.form1.txtemail.focus();
            return false;
        }

        if (document.form1.txtmessage.value == '') {
            alert("Message Field can not be blank...");
            document.form1.txtmessage.focus();
            return false;
        }

        var check = true;
        var value = document.form1.txtphoneno.value;

        for (var i = 0; i < document.form1.txtphoneno.value.length; ++i) {
            var new_key = value.charAt(i);
            if (((new_key < '0') || (new_key > '9')) && !(new_key == '')) {
                check = false;
                alert("Phone Number Not Valid...");
                document.form1.txtphoneno.focus();
                return false;
            }
        }
    }
    alert("Mail Send Successfully...");
    return true;
}
