﻿

function isValidEmail(strEmail) {
    validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
    strEmail = document.forms[0].email.value;

    // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) {
        alert('A valid e-mail address is required.\nPlease amend and retry');
        return false;
    }
    return true;
}

function Checkvalidation() {

    var err = '';
    var txtname = document.getElementById('txtname');
    var txtmail = document.getElementById('txtmail');
    var txtComment = document.getElementById('txtComment');
    var txtCode = document.getElementById('txtCode');
    var myfocus = '';
    if (txtname.value == '') {
        err = err + 'Please Enter Name\n';
        myfocus = myfocus + ":txtname";
    }
    if (txtmail.value == '') {
        err = err + 'Please Enter Email\n';
        myfocus = myfocus + ":txtmail";
    }

    if (txtmail.value != '') {
        validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
        if (txtmail.value.search(validRegExp) == -1) {
            err = err + "Please Enter Valid Email\n";
            myfocus = myfocus + ":txtmail";
        }
    }
    if (txtComment.value == '') {
        err = err + "Please Enter Comment\n";
        myfocus = myfocus + ":txtComment";
    }
    if (txtCode.value == '') {
        err = err + "Please Enter Code\n";
        myfocus = myfocus + ":txtCode";
    }

    if (err != '') {
        alert(err);
        var myControl = myfocus.split(':');
        document.getElementById(myControl[1]).focus();
        return false;
    }
}

function checkemailvalid() {

    var err = '';
    var txtEmail = document.getElementById('txtEmail');
    var myfocus = '';
    if (txtEmail.value == '') {
        err = err + 'Please Enter Email\n';
        myfocus = myfocus + ":txtEmail";
    }

    if (txtEmail.value != '') {
        validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
        if (txtEmail.value.search(validRegExp) == -1) {
            err = err + "Please Enter Valid Email\n";
            myfocus = myfocus + ":txtEmail";
        }
    }
    if (err != '') {
        alert(err);
        var myControl = myfocus.split(':');
        document.getElementById(myControl[1]).focus();
        return false;
    }
}
