function chk_Empty(obj) {
    if (obj.value == "") {
        alert(obj.title + " should not be blank.");
        obj.focus();
        return false;
    }
    return true;
}

function chk_Char(obj) {
    for (var j = 0; j < obj.value.length; j ++) {
        c = obj.value.charAt(j);
        switch (c)  {
            case '#':
                return false;
            case '%':
                return false;
            case '^':
                return false;
            case '&':
                return false;
            case '*':
                return false;
            case '<':
                return false;
            case '>':
                return false;
            case '/':
                return false;
        }
    }
    return true;
}

function chk_Length(obj, len) {
    if (obj.value != "" && obj.value.replace(/[^\x00-\xFF]/g, '**').length > len) {
        alert(obj.title + " should be within " + len + " characters.");
        obj.focus();
        obj.select();
        return false;
    }
    return true;
}

function chk_email(obj) {
    var zz = /^[a-zA-Z]([a-zA-Z0-9]*[-_.]?[a-zA-Z0-9]+)+@([\w-]+\.)+[a-zA-Z]{2,}$/;
    if (!zz.test(obj.value)) {
        alert("Please enter correct Email format.");
        obj.focus();
        obj.select();
        return false;
    }
    return true;
}

function check_Form(frm) {
    for (var i = 0; i < frm.elements.length; i ++) {
        var elmnt = frm.elements[i];
        if (elmnt.type == "text" || elmnt.type == "textarea") {
            if (elmnt.alt == "Y") {
                if (!chk_Empty(elmnt)) return false;
            }
            if (!chk_Char(elmnt)) {
                alert("No illegal character(#,%,^,&,*,<,>,/)");
                elmnt.focus();
                elmnt.select();
                return false;
            }
            if (elmnt.maxLength != "") {
                if (!chk_Length(elmnt, elmnt.maxLength)) return false;
            }
        }
    }
    return true;
}
