//Locking all the numbers and special characters
//function chckMaxLength(para){    
//      if (para.value.length>250)
//      {
//        var desc = para.value;
//        var descstr = desc.substring(0,250);
//        var control=para;
//        document.getElementById(control.id).value = descstr; 
//        alert("Maximum length is 250");
//        return false;
//      }
//    }
function character_only(e, ctrl) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else if (event) keycode = event.keyCode;
    else return true;
    if (keycode >= 0 && keycode <= 254) {
        selected_text = '';
        if (document.selection) {
            var selection = document.selection.createRange();
            var selected_text = selection.text;
        }
        else if (document.getSelection) {
            var start = ctrl.selectionStart;
            var end = ctrl.selectionEnd;
            var selected_text = ctrl.value.substring(start, end);
        }
        if (keycode == 0 || keycode == 8) {
            return true;
        }
        //keycodes allowed but not in the beginning - space
        if ((keycode == 32) && (((ctrl.value).length == 0) || selected_text != "")) {
            return false;
        }
        if (!(keycode >= 65 && keycode <= 90) && !(keycode >= 97 && keycode <= 122) && (keycode != 13) && (keycode != 46) && (keycode != 45) && (keycode != 44) && (keycode != 39) && (keycode != 34) && (keycode != 95)) {
            return false;
        }
        else return true;
    }
    else {
        return true;
    }
}
//Locking all characters and special characters
function number_only(e, ctrl) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (document.selection) {
        var selection = document.selection.createRange();
        var selected_text = selection.text;
    }
    else if (document.getSelection) {
        var start = ctrl.selectionStart;
        var end = ctrl.selectionEnd;
        var selected_text = ctrl.value.substring(start, end);
    }
    if (keycode == 0 || keycode == 8) {
        return true;
    }
    //keycodes allowed but not in the beginning - 0
    if (keycode == 48 && ((ctrl.value).length == 0 || selected_text != "")) {
        return false;
    }
    if (!(keycode >= 48 && keycode <= 57) && (keycode != 13)) {
        return false;
    }
    else return true;
}
function chk_number_only(e) {
    debugger;
    chr_allow = /[0-9]/g;
    val = e.value;
    val = val.replace(chr_allow, '');
    len = val.length;
    val2 = e.value;
    for (i = 0; i < len; i++) {
        val2 = val2.replace(val.charAt(i), '');
    }
    e.value = val2;
    if (e.value != '' && e.value == 0) {
        alert('Invalid Number');
        e.focus();
        return false;
    }
    return false;
}
function chk_character_number(e) {
    debugger;
    chr_allow = /[a-zA-Z0-9 ]/g;
    val = e.value;
    val = val.replace(chr_allow, '');
    len = val.length;
    val2 = e.value;
    for (i = 0; i < len; i++) {
        val2 = val2.replace(val.charAt(i), '');
    }
    e.value = val2;
    chk_blank(e);
    return false;
}
function character_number(e) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (keycode >= 0 && keycode <= 254) {
        if (document.selection) {
            var selection = document.selection.createRange();
            var selected_text = selection.text;
        }
        //keycodes allowed but not in the beginning - space
        if (((e.value).length == 0 || selected_text != "") && (keycode == 32 || (keycode >= 48 && keycode <= 57))) {
            return false;
        }
        if (!(keycode >= 65 && keycode <= 90) && !(keycode >= 97 && keycode <= 122) && (keycode != 13) && (keycode != 32) && !(keycode >= 48 && keycode <= 57)) {
            return false;
        }
        else return true;
    }
    else {
        return true;
    }
}
function chk_alphanumeric_only(e, ctrl) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (keycode >= 0 && keycode <= 254) {
        if (document.selection) {
            var selection = document.selection.createRange();
            var selected_text = selection.text;
        }
        else if (document.getSelection) {
            var start = ctrl.selectionStart;
            var end = ctrl.selectionEnd;
            var selected_text = ctrl.value.substring(start, end);
        }
        if (keycode == 0 || keycode == 8) {
            return true;
        }
        //keycodes allowed but not in the beginning - space
        if (((ctrl.value).length == 0 || selected_text != "") && (keycode == 32)) {
            return false;
        }
        if (!(keycode >= 65 && keycode <= 90) && !(keycode >= 97 && keycode <= 122) && (keycode != 13) && (keycode != 32) && !(keycode >= 48 && keycode <= 57)) {
            return false;
        }
        else return true;
    }
    else {
        return true;
    }
}
function character_numbers_Special(e) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (keycode >= 0 && keycode <= 254) {
        var selection = document.selection.createRange();
        var selected_text = selection.text;
        //keycodes allowed but not in the beginning - space
        if (((e.value).length == 0 || selected_text != "") && (keycode == 32 || (keycode >= 48 && keycode <= 57))) {
            return false;
        }
        if (keycode != 13) {
            return false;
        }
        else return true;
    }
    else {
        return true;
    }
}
function chk_number_dot(e) {
    debugger;
    chr_allow = /[0-9]/g;
    val = e.value;
    val = val.replace(chr_allow, '');
    len = val.length;
    val2 = e.value;
    dot_occured = 0;
    for (i = 0; i < len; i++) {
        if (!(dot_occured == 0 && val.charAt(i) == '.')) {
            val2 = val2.replace(val.charAt(i), '');
        }
        if (val.charAt(i) == '-') dot_occured = 1;
    }
    e.value = val2;
    first_chr = (e.value).charAt(0);
    if (e.value != '' && (first_chr == '.' || e.value == 0)) {
        alert('Invalid Number');
        e.focus();
        return false;
    }
    else if (e.value != '') {
        e.value = parseFloat(e.value);
    }
    return false;
}
//Locking the All characters and special characters except -
function phone_number(e) {
    debugger;
    dec_limit = arguments[1];
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    val = e.value;
    dot_index = val.indexOf('-');
    /*if(dot_index != -1)
    {
        dec_pts = (val.length - dot_index);
        if(!dec_limit) dec_limit = 3; else dec_limit = dec_limit + 1;
        //if(dec_pts >=dec_limit) return false;
    }*/
    var selection = document.selection.createRange();
    var selected_text = selection.text;
    //keycodes allowed but not in the beginning - 0,dot
    if ((val.length == 0 || selected_text != "") && (keycode == 45))	// || keycode==48
    {
        return false;
    }
        /*else if(dot_index != -1 && keycode == 45 )
		{
			return false;
		}*/
    else if (!(keycode >= 48 && keycode <= 57) && (keycode != 13) && (keycode != 45) && (keycode != 44) && (keycode != 47)) {
        return false;
    }
    else return true;
}
//Price lock
function number_dot(e, ctrl) {
    debugger;
    dec_limit = arguments[1];
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    //		alert('number_dot');
    val = ctrl.value;
    dot_index = val.indexOf('.');
    if (dot_index != -1) {
        dec_pts = (val.length - dot_index);
        if (!dec_limit) dec_limit = 3; else dec_limit = dec_limit + 1;
        //if(dec_pts >=dec_limit) return false;
    }
    if (document.selection) {
        var selection = document.selection.createRange();
        var selected_text = selection.text;
    }
    else if (document.getSelection) {
        var start = ctrl.selectionStart;
        var end = ctrl.selectionEnd;
        var selected_text = ctrl.value.substring(start, end);
    }
    //keycodes allowed but not in the beginning - 0,dot
    if ((val.length == 0 || selected_text != "") && (keycode == 46))	// || keycode==48
    {
        return false;
    }
    else if (dot_index != -1 && keycode == 46) {
        return false;
    }
    else if (!(keycode >= 48 && keycode <= 57) && (keycode != 13) && (keycode != 46) && (keycode != 36) && (keycode != 8) && (keycode != 0) && (keycode != 58)) {
        return false;
    }
    else return true;
}
//Added by Manjula.P on 20-Jul-2013 for validating noofvalidates textbox values to employee andd and employee modify page
function minmax(value, max) {
    if (parseInt(value) > max)
        return max;
    else return value;
}
//function for checking number in no of leave taken by Manjula.P on 25-Jul-2013
function number_dot_Without_Dollar(e, ctrl) {
    dec_limit = arguments[1];
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    //		alert('number_dot');
    val = ctrl.value;
    dot_index = val.indexOf('.');
    if (dot_index != -1) {
        dec_pts = (val.length - dot_index);
        if (!dec_limit) dec_limit = 3; else dec_limit = dec_limit + 1;
        //if(dec_pts >=dec_limit) return false;
    }
    if (document.selection) {
        var selection = document.selection.createRange();
        var selected_text = selection.text;
    }
    else if (document.getSelection) {
        var start = ctrl.selectionStart;
        var end = ctrl.selectionEnd;
        var selected_text = ctrl.value.substring(start, end);
    }
    //keycodes allowed but not in the beginning - 0,dot
    if ((val.length == 0 || selected_text != "") && (keycode == 46))	// || keycode==48
    {
        return false;
    }
    else if (dot_index != -1 && keycode == 46) {
        return false;
    }
        //dollar
    else if (keycode == 36) {
        return false;
    }
    else if (!(keycode >= 48 && keycode <= 57) && (keycode != 13) && (keycode != 46) && (keycode != 36) && (keycode != 8) && (keycode != 0)) {
        return false;
    }
    else return true;
}
//function for checking half day leave in employee master by MAnjula.P on 25-Jul-2013
function onChangeHalfDay(ctrl) {
    var afterdecimal = 0;
    val = ctrl.value;
    dot_index = val.indexOf('.');
    if (dot_index != -1) {
        afterdecimal = (val.toString().split('.')[1]);
        if (afterdecimal > 0) {
            if (((afterdecimal != "50") && (afterdecimal != "00")) && (afterdecimal != "5")) {
                ctrl.value = "";
                return false;
            }
            else {
                return true;
            }
        }
        else {
            return true;
        }
    }
    else {
        return true;
    }
}
// function for input 2 numbers after the decimal point
function onChangetwodecimalDay(ctrl) {
    var afterdecimal = 0;
    val = ctrl.value;
    dot_index = val.indexOf('.');
    if (dot_index != -1) {
        afterdecimal = (val.toString().split('.')[1]);
        if (afterdecimal > 99) {
            ctrl.value = "";
        }
        else {
            return true;
        }
    }
    else {
        return true;
    }
}

function onkeyup(e) {
    debugger;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    var pressedKey = String.fromCharCode(keycode).toLowerCase();
    if (event.ctrlKey && (pressedKey == "v")) // pressedKey == "c" ||
    {
        // disable key press porcessing
        event.returnValue = false;
    }
}
//Locking the All special characters except @ and _
function username(e) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (keycode >= 0 && keycode <= 254) {
        var selection = document.selection.createRange();
        var selected_text = selection.text;
        //keycodes allowed but not in the beginning - space
        if (((e.value).length == 0 || selected_text != "") && (keycode == 32))// || (keycode>=48 && keycode <=57)))
        {
            return false;
        }
        if (!(keycode >= 64 && keycode <= 90) && !(keycode >= 97 && keycode <= 122) && (keycode != 95) && (keycode != 13) && (keycode != 46) && !(keycode >= 48 && keycode <= 57)) {
            return false;
        }
        else return true;
    }
    else {
        return true;
    }
}
//Open new window
function acceptUserNameWithOutSpace(e) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if ((keycode >= 65 && keycode <= 132) || (keycode >= 97 && keycode <= 122) || (keycode >= 48 && keycode <= 57) || (keycode == 46) || (keycode == 64) || (keycode == 95)) {
        return true;
    }
    else {
        return false;
    }
}
//Accept space only after character
function spaceAfterChr(e) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    var selection = document.selection.createRange();
    var selected_text = selection.text;
    //keycodes allowed but not in the beginning - space
    if (((e.value).length == 0 || selected_text != "") && (keycode == 32))// || (keycode>=48 && keycode <=57)))
    {
        return false;
    }
    if (!(keycode >= 65 && keycode <= 90) && !(keycode >= 97 && keycode <= 122) && (keycode != 13) && (keycode != 32) && (keycode != 46) && !(keycode >= 48 && keycode <= 57)) {
        return false;
    }
    else return true;
}
//Initial
function acceptInitial(e) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    var selection = document.selection.createRange();
    var selected_text = selection.text;
    //keycodes allowed but not in the beginning - space
    if (((e.value).length == 0 || selected_text != "") && (keycode == 32)) {
        return false;
    }
    if ((keycode == 32) || (keycode >= 65 && keycode <= 90) || (keycode >= 97 && keycode <= 122) || (keycode == 46)) {
        return true
    }
    else {
        return false;
    }
}
function acceptSocialSecurityNumber(e) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    var selection = document.selection.createRange();
    var selected_text = selection.text;
    //keycodes allowed but not in the beginning - space
    if (((e.value).length == 0 || selected_text != "") && (keycode == 32)) {
        return false;
    }
    //if((keycode>=48 && keycode<=57) || (keycode>=65 && keycode<=90) || (keycode>=97 && keycode<=122) || (keycode==40) || (keycode==41) || (keycode==45))
    //{
    //	return true
    //}
    if ((keycode >= 48 && keycode <= 57) || (keycode == 40) || (keycode == 41) || (keycode == 45)) {
        return true
    }
    else {
        return false;
    }
}
function acceptAddress(e, ctrl) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (keycode >= 0 && keycode <= 254) {
        if (document.selection) {
            var selection = document.selection.createRange();
            var selected_text = selection.text;
        }
        else if (document.getSelection) {
            var start = ctrl.selectionStart;
            var end = ctrl.selectionEnd;
            var selected_text = ctrl.value.substring(start, end);
        }
        //keycodes allowed but not in the beginning - space
        if (((ctrl.value).length == 0 || selected_text != "") && (keycode == 32)) {
            return false;
        }
        if (keycode == 0 || keycode == 8) {
            return true;
        }
    }
    else {
        return true;
    }
    //Address accept all keys	
    /*if((keycode>=48 && keycode<=57) || (keycode>=65 && keycode<=90) || (keycode>=97 && keycode<=122) || (keycode==32) || (keycode==35) || (keycode==44) || (keycode==46))
    {
        return true
    }
    else
    {
        return false;	
    }	*/
}
function acceptPhoneNumbers(e) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    var selection = document.selection.createRange();
    var selected_text = selection.text;
    //keycodes allowed but not in the beginning - space
    if (((e.value).length == 0 || selected_text != "") && (keycode == 32)) {
        return false;
    }
    if ((keycode >= 48 && keycode <= 57) || (keycode == 32) || (keycode == 43) || (keycode == 45) || (keycode == 40) || (keycode == 41)) {
        return true
    }
    else {
        return false;
    }
}
function acceptZipCode(e) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    var selection = document.selection.createRange();
    var selected_text = selection.text;
    //keycodes allowed but not in the beginning - space
    if (((e.value).length == 0 || selected_text != "") && (keycode == 32)) {
        return false;
    }
    if ((keycode >= 48 && keycode <= 57) || (keycode == 45)) {
        return true
    }
    else {
        return false;
    }
}
function acceptOccupation(e) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (keycode >= 0 && keycode <= 254) {
        var selection = document.selection.createRange();
        var selected_text = selection.text;
        //keycodes allowed but not in the beginning - space
        if (((e.value).length == 0 || selected_text != "") && (keycode == 32)) {
            return false;
        }
        if ((keycode >= 97 && keycode <= 122) || (keycode >= 65 && keycode <= 90) || (keycode == 32) || (keycode == 44)) {
            return true
        }
        else {
            return false;
        }
    }
    else {
        return true;
    }
}
function acceptNames(e, ctrl) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (keycode >= 0 && keycode <= 254) {
        if (document.selection) {
            var selection = document.selection.createRange();
            var selected_text = selection.text;
        }
        else if (document.getSelection) {
            var start = ctrl.selectionStart;
            var end = ctrl.selectionEnd;
            var selected_text = ctrl.value.substring(start, end);
        }
        //keycodes allowed but not in the beginning - space
        if (((ctrl.value).length == 0 || selected_text != "") && (keycode == 32)) {
            return false;
        }
        if ((keycode >= 97 && keycode <= 122) || (keycode >= 65 && keycode <= 90) || (keycode == 32) || (keycode == 46) || (keycode == 8) || (keycode == 0)) {
            return true
        }
        else {
            return false;
        }
    }
    else {
        return true;
    }
}
function acceptVisitTime(e) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    var selection = document.selection.createRange();
    var selected_text = selection.text;
    //keycodes allowed but not in the beginning - space
    if (((e.value).length == 0 || selected_text != "") && (keycode == 32)) {
        return false;
    }
    if ((keycode >= 48 && keycode <= 57 || (keycode == 58))) {
        return true
    }
    else {
        return false;
    }
}
function acceptCharacterNumber(e, ctrl) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (keycode >= 0 && keycode <= 254) {
        if (document.selection) {
            var selection = document.selection.createRange();
            var selected_text = selection.text;
        }
        else if (document.getSelection) {
            var start = ctrl.selectionStart;
            var end = ctrl.selectionEnd;
            var selected_text = ctrl.value.substring(start, end);
        }
        //keycodes allowed but not in the beginning - space
        if (((ctrl.value).length == 0 || selected_text != "") && (keycode == 32)) {
            return false;
        }
        if (keycode == 0 || keycode == 8) {
            return true;
        }
        if (!(keycode >= 65 && keycode <= 90) && !(keycode >= 97 && keycode <= 122) && (keycode != 13) && (keycode != 32) && !(keycode >= 48 && keycode <= 57)) {
            return false;
        }
        else return true;
    }
    else {
        return true;
    }
}
function acceptLicenseNumbers(e) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    var selection = document.selection.createRange();
    var selected_text = selection.text;
    //keycodes allowed but not in the beginning - space
    if (((e.value).length == 0 || selected_text != "") && (keycode == 32)) {
        return false;
    }
    if ((keycode >= 48 && keycode <= 57) || (keycode == 45) || (keycode >= 65 && keycode <= 90) || (keycode >= 97 && keycode <= 122)) {
        return true
    }
    else {
        return false;
    }
}
//Only one allow decimal
function fun_AllowOnlyAmountAndDot(e, ctrl) {
    debugger;
    var keyCode;
    if (window.event) keyCode = window.event.keyCode;
    else if (e) keyCode = e.which;
    else return true;
    if (keyCode == 0 || keyCode == 8) {
        return true;
    }
    if (keyCode > 47 && keyCode < 58 || keyCode == 46) {
        var txtbx = document.getElementById(ctrl);
        var amount = document.getElementById(ctrl).value;
        var present = 0;
        var count = 0;

        if (amount.indexOf(".", present) || amount.indexOf(".", present + 1));
        {
            // alert('0');
        }

        /*if(amount.length==2)
        {
        if(event.keyCode != 46)
        return false;
        }*/
        do {
            present = amount.indexOf(".", present);
            if (present != -1) {
                count++;
                present++;
            }
        }
        while (present != -1);
        if (present == -1 && amount.length == 0 && keyCode == 46) {
            keyCode = 0;
            //alert("Wrong position of decimal point not  allowed !!");
            return false;
        }

        if (count >= 1 && keyCode == 46) {

            keyCode = 0;
            //alert("Only one decimal point is allowed !!");
            return false;
        }
        if (count == 1) {
            var lastdigits = amount.substring(amount.indexOf(".") + 1, amount.length);
            if (lastdigits.length >= 2) {
                //alert("Two decimal places only allowed");
                keyCode = 0;
                return false;
            }
        }
        return true;
    }
    else {
        keyCode = 0;
        //alert("Only Numbers with dot allowed !!");
        return false;
    }

}

//Time check
function number_colon(e, ctrl) {
    debugger;
    dec_limit = arguments[1];
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    val = ctrl.value;
    dot_index = val.indexOf(':');
    if (dot_index != -1) {
        dec_pts = (val.length - dot_index);
        if (!dec_limit) dec_limit = 3; else dec_limit = dec_limit + 1;
        //if(dec_pts >=dec_limit) return false;
    }
    if (document.selection) {
        var selection = document.selection.createRange();
        var selected_text = selection.text;
    }
    else if (document.getSelection) {
        var start = ctrl.selectionStart;
        var end = ctrl.selectionEnd;
        var selected_text = ctrl.value.substring(start, end);
    }
    // commented by christopher for not accepting 0 in Leave Policy permission txt box
    //keycodes allowed but not in the beginning - 0,dot
    //		if(	(val.length==0 || selected_text != "") && (keycode == 48))//||(keycode==48))
    //		{	
    //			return false;
    //		} else
    if (keycode == 0 || keycode == 8) {
        return true;
    }
    if (dot_index != -1 && keycode == 58) {
        return false;
    }
    else if (!(keycode >= 48 && keycode <= 57) && (keycode != 13) && (keycode != 58)) {
        return false;
    }
    else return true;
}
//Number,colon,space,AM and PM
function number_colon_Space_AM_PM(e, ctrl) {
    debugger;
    dec_limit = arguments[1];
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    val = ctrl.value;
    dot_index = val.indexOf(':');
    if (dot_index != -1) {
        dec_pts = (val.length - dot_index);
        if (!dec_limit) dec_limit = 3; else dec_limit = dec_limit + 1;
        //if(dec_pts >=dec_limit) return false;
    }
    if (document.selection) {
        var selection = document.selection.createRange();
        var selected_text = selection.text;
    }
    else if (document.getSelection) {
        var start = ctrl.selectionStart;
        var end = ctrl.selectionEnd;
        var selected_text = ctrl.value.substring(start, end);
    }
    // commented by christopher for not accepting 0 in Leave Policy permission txt box
    //keycodes allowed but not in the beginning - 0,dot
    //		if(	(val.length==0 || selected_text != "") && (keycode == 48))//||(keycode==48))
    //		{	
    //			return false;
    //		} else
    if (keycode == 0 || keycode == 8) {
        return true;
    }
    if (dot_index != -1 && keycode == 58) {
        return false;
    }
    else if (keycode == 32 || keycode == 80 || keycode == 77 || keycode == 65) {
        return true;
    }
    else if (!(keycode >= 48 && keycode <= 57) && (keycode != 13) && (keycode != 58)) {
        return false;
    }
    else return true;
}
//Date Checking	
function Date_format(e) {
    debugger;
    dec_limit = arguments[1];
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    val = e.value;
    dot_index = val.indexOf('-');
    /*if(dot_index != -1)
    {
        dec_pts = (val.length - dot_index);
        if(!dec_limit) dec_limit = 3; else dec_limit = dec_limit + 1;
        //if(dec_pts >=dec_limit) return false;
    }*/
    var selection = document.selection.createRange();
    var selected_text = selection.text;
    if (((e.value).length == 0 || selected_text != "") && (keycode == 32)) {
        return false;
    }
    //keycodes allowed but not in the beginning - 0,dot
    if ((val.length == 0 || selected_text != "") && (keycode == 45))	// || keycode==48
    {
        return false;
    }
        /*else if(dot_index != -1 && keycode == 45 )
        {
            return false;
        }*/
    else if (!(keycode >= 48 && keycode <= 57) && (keycode != 13) && (keycode != 47))// && (keycode!=44) && (keycode!=45))//&& (keycode!=32))
    {
        return false;
    }
    else return true;
}
//av - without space
function character_number_nospace(e, ctrl) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (keycode >= 0 && keycode <= 254) {
        if (document.selection) {
            var selection = document.selection.createRange();
            var selected_text = selection.text;
        }
        else if (document.getSelection) {
            var start = ctrl.selectionStart;
            var end = ctrl.selectionEnd;
            var selected_text = ctrl.value.substring(start, end);
        }
        //keycodes allowed but not in the beginning - space
        if (((ctrl.value).length == 0 || selected_text != "") && (keycode == 32)) {
            return false;
        }
        if (keycode == 0 || keycode == 8) {
            return true;
        }
        if (!(keycode >= 65 && keycode <= 90) && !(keycode >= 97 && keycode <= 122) && (keycode != 13) && !(keycode >= 48 && keycode <= 57)) {
            return false;
        }
        else return true;
    }
    else {
        return true;
    }
}
//av - without space - PWD
function character_number_nospace_pwd(e, ctrl) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (keycode >= 0 && keycode <= 254) {
        if (document.selection) {
            var selection = document.selection.createRange();
            var selected_text = selection.text;
        }
        else if (document.getSelection) {
            var start = ctrl.selectionStart;
            var end = ctrl.selectionEnd;
            var selected_text = ctrl.value.substring(start, end);
        }
        //keycodes allowed but not in the beginning - space		
        if (((ctrl.value).length == 0 || selected_text != "") && ((keycode == 32) || (keycode == 39) || (keycode == 126) || (keycode == 96) || (keycode == 33) || (keycode == 64) || (keycode == 35) || (keycode == 36) || (keycode == 37) || (keycode == 94) || (keycode == 38) || (keycode == 42) || (keycode == 40) || (keycode == 41) || (keycode == 45) || (keycode == 95) || (keycode == 61) || (keycode == 43) || (keycode == 92) || (keycode == 124) || (keycode == 91) || (keycode == 123) || (keycode == 93) || (keycode == 125) || (keycode == 44) || (keycode == 60) || (keycode == 46) || (keycode == 62) || (keycode == 47) || (keycode == 63) || (keycode == 34))) {
            return false;
        }
        if (keycode == 0 || keycode == 8) {
            return true;
        }
        if (!(keycode >= 65 && keycode <= 90) && !(keycode >= 97 && keycode <= 122) && !(keycode >= 33 && keycode <= 47) && (keycode != 13) && !(keycode >= 48 && keycode <= 57)) {
            return false;
        }
        else return true;
    }
    else {
        return true;
    }
}
// Locking All the Special Characters 
function LockSpecialCharacters(e) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (keycode >= 0 && keycode <= 254) {
        var selection = document.selection.createRange();
        var selected_text = selection.text;
        //keycodes allowed but not in the beginning - space
        if (((e.value).length == 0 || selected_text != "") && (keycode == 32))// || (keycode>=48 && keycode <=57)))
        {
            return false;
        }
        if (!(keycode >= 65 && keycode <= 90) && !(keycode >= 97 && keycode <= 122) && (keycode = 95) && (keycode != 13) && (keycode = 46) && (keycode >= 48 && keycode <= 57)) {
            return false;
        }
        else return true;
    }
    else {
        return true;
    }
}
// Accepting all the Special Characters 
function AcceptOnlySpecialCharacters(e, ctrl) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (document.selection) {
        var selection = document.selection.createRange();
        var selected_text = selection.text;
    }
    else if (document.getSelection) {
        var start = ctrl.selectionStart;
        var end = ctrl.selectionEnd;
        var selected_text = ctrl.value.substring(start, end);
    }
    //keycodes allowed but not in the beginning - space
    if (((ctrl.value).length == 0 || selected_text != "") && (keycode == 32))// || (keycode>=48 && keycode <=57)))
    {
        return false;
    }
    if (keycode == 0 || keycode == 8) {
        return true;
    }
    if ((keycode >= 65 && keycode <= 90) || (keycode >= 97 && keycode <= 122) || (keycode >= 48 && keycode <= 57))
        // (keycode=95) && (keycode!=13) && (keycode=46) 
    {
        return false;
    }
    else {
        return true;
    }
}
// Accept Characters
function acceptChars(e) {
    debugger;
    var code = (window.event) ? e.keyCode : e.which;
    if (code >= 0 && code <= 254) {
        if ((code >= 65 && code <= 90) || (code >= 97 && code <= 122) || code == 8 || code == 32 || code == 0 || code == 13 || code == 9)
            return true;
        else
            return false;
    }
    else {
        return true;
    }
}
//Completed
function acceptChars_MaxLength(e, ctrl, length, len) {
    debugger;
    debugger;
    var code = (window.event) ? e.keyCode : e.which;
    if (code >= 0 && code <= 254) {
        if ((code >= 65 && code <= 90) || (code >= 97 && code <= 122) || code == 8 || code == 32 || code == 0 || code == 13 || code == 9 || code == 95 || code == 45)
            //return CheckMaximumLength(ctrl,length);
            if (code == 95 || code == 45) {
                return true;
            }
            else {
                return chkMaxLen(e, ctrl, length, len);
            }
            // return true;
        else
            return false;
    }
    else {
        return true;
    }
}
//Check Scheduler Name with (-)
function Scheduler_AcceptChars_MaxLength(e, ctrl, length, MaxLength) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (keycode >= 0 && keycode <= 254) {
        if (document.selection) {
            var selection = document.selection.createRange();
            var selected_text = selection.text;
        }
        else if (document.getSelection) {
            var start = ctrl.selectionStart;
            var end = ctrl.selectionEnd;
            var selected_text = ctrl.value.substring(start, end);
        }
        //keycodes allowed but not in the beginning - space && (keycode == 32 )
        //		    if((length==0 || selected_text != ""))
        //		    {
        //			    return false;
        //		    }
        if (keycode == 0 || keycode == 8 || keycode == 45 || keycode == 32) {
            return true;
        }
        if (!(keycode >= 65 && keycode <= 90) && !(keycode >= 97 && keycode <= 122) && (keycode != 13) && !(keycode >= 48 && keycode <= 57)) {
            return false;
        }
        else {
            //alert(length);
            return CheckMaximumLength(ctrl, length, MaxLength);
            //return true;
        }
    }
    else {
        return true;
    }
}
function acceptChars_MaxLengthForLevel(e, ctrl, length, len) {
    debugger;
    debugger;
    var code = (window.event) ? e.keyCode : e.which;
    if (code >= 0 && code <= 254) {
        if ((code >= 65 && code <= 90) || (code >= 97 && code <= 122) || code == 8 || code == 32 || code == 0 || code == 13 || code == 9 || code == 95 || code == 45 || code == 173)
            //return CheckMaximumLength(ctrl,length);
            return chkMaxLen(e, ctrl, length, len);
            // return true;
        else
            return false;
    }
    else {
        return true;
    }
}
//Accept Characters, Number only
function acceptCharsNum_MaxLength(e, ctrl, length, MaxLength) {
    debugger;
    var keycode;
    
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    //alert(keycode);
    if (keycode >= 0 && keycode <= 254) {
        if (document.selection) {
            var selection = document.selection.createRange();
            var selected_text = selection.text;
        }
        else if (document.getSelection) {
            var start = ctrl.selectionStart;
            var end = ctrl.selectionEnd;
            var selected_text = ctrl.value.substring(start, end);
        }
        //keycodes allowed but not in the beginning - space
        if ((length == 0 || selected_text != "") && (keycode == 32)) {
            return false;
        }
        if (keycode == 0 || keycode == 8 || keycode == 45) {
            return true;
        }
        if (!(keycode >= 65 && keycode <= 90) && !(keycode >= 97 && keycode <= 122) && (keycode != 13) && !(keycode >= 48 && keycode <= 57)) {
            return false;
        }
        else {
            //alert(length);
            return CheckMaximumLength(ctrl, length, MaxLength);
            //return true;
        }
    }
    else {
        return true;
    }
}
//Accept Characters, Number,ampersand, underscore only
function acceptCharsNumAmpUnder_MaxLength(e, ctrl, length, MaxLength) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (keycode >= 0 && keycode <= 254) {
        if (document.selection) {
            var selection = document.selection.createRange();
            var selected_text = selection.text;
        }
        else if (document.getSelection) {
            var start = ctrl.selectionStart;
            var end = ctrl.selectionEnd;
            var selected_text = ctrl.value.substring(start, end);
        }
        //keycodes allowed but not in the beginning - space
        if ((length == 0 || selected_text != "") && (keycode == 32)) {
            return false;
        }
        if (keycode == 0 || keycode == 8 || (keycode == 32)) {
            return true;
        }
        if (!(keycode >= 65 && keycode <= 90) && !(keycode >= 97 && keycode <= 122) && (keycode != 13) && !(keycode >= 48 && keycode <= 57) && (keycode != 38) && (keycode != 95) && (keycode != 45)) {
            return false;
        }
        else {
            //alert(length);
            return CheckMaximumLength(ctrl, length, MaxLength);
            //return true;
        }
    }
    else {
        return true;
    }
}
//Locking the All special characters except @ and _
function employeename_singlequotes_maxlength(e, ctrl, length, MaxLength) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (keycode >= 0 && keycode <= 254) {
        if (document.selection) {
            var selection = document.selection.createRange();
            var selected_text = selection.text;
        }
        else if (document.getSelection) {
            var start = ctrl.selectionStart;
            var end = ctrl.selectionEnd;
            var selected_text = ctrl.value.substring(start, end);
        }
        //modified on 21-Jun-2010
        //keycodes allowed but not in the beginning - space
        //		if((length==0 || selected_text != "") && (keycode==32))// || (keycode>=48 && keycode <=57)))
        //		{
        //			return false;
        //		}
        if ((keycode == 0) || (keycode == 8) || (keycode == 32)) {
            return true;
        }
        if (!(keycode >= 65 && keycode <= 90) && !(keycode >= 97 && keycode <= 122) && (keycode != 13) && (keycode != 39) && (keycode != 32) && (keycode != 46)) {
            return false;
        }
        else {
            return CheckMaximumLength(ctrl, length, MaxLength);
        }
    }
    else {
        return true;
    }
}
// Allowing All Characters and '-' and '/' and ':' to get the Date and Time Format
function DateTimeFormats_CharacterOnly(e, ctrl) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else if (event) keycode = event.keyCode;
    else return true;
    selected_text = '';
    if (document.selection) {
        var selection = document.selection.createRange();
        var selected_text = selection.text;
    }
    else if (document.getSelection) {
        var start = ctrl.selectionStart;
        var end = ctrl.selectionEnd;
        var selected_text = ctrl.value.substring(start, end);
    }
    //keycodes allowed but not in the beginning - space
    if ((keycode == 32) && (((ctrl.value).length == 0) || selected_text != "")) {
        return false;
    }
    // The Special Characters '-','/' and ':' not allowed in the beginning
    if (((keycode == 45) || (keycode == 47) || (keycode == 58)) && (((ctrl.value).length == 0) || selected_text != "")) {
        return false;
    }
    if ((keycode >= 65 && keycode <= 90) || (keycode >= 97 && keycode <= 122) || (keycode == 45) || (keycode == 47) || (keycode == 58) || (keycode == 32)) {
        return true;
    }
    if (keycode == 8 || keycode == 0) {
        return true;
    }
    else return false;
}
// Allowing All Characters and '-' and '/' to get the Date Format
function DateFormats_CharacterOnly(e, ctrl) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else if (event) keycode = event.keyCode;
    else return true;
    selected_text = '';
    if (document.selection) {
        var selection = document.selection.createRange();
        var selected_text = selection.text;
    }
    else if (document.getSelection) {
        var start = ctrl.selectionStart;
        var end = ctrl.selectionEnd;
        var selected_text = ctrl.value.substring(start, end);
    }
    //keycodes allowed but not in the beginning - space
    if ((keycode == 32) && (((ctrl.value).length == 0) || selected_text != "")) {
        return false;
    }
    // The Special Characters '-' and '/' not allowed in the beginning
    if (((keycode == 45) || (keycode == 47)) && (((e.value).length == 0) || selected_text != "")) {
        return false;
    }
    if ((keycode >= 65 && keycode <= 90) || (keycode >= 97 && keycode <= 122) || (keycode == 45) || (keycode == 47) || (keycode == 32)) {
        return true;
    }
    if (keycode == 8 || keycode == 0) {
        return true;
    }
    else return false;
}
// Allowing All Characters and ':' to get the Time Format
function TimeFormats_CharacterOnly(e, ctrl) {
    debugger;
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else if (event) keycode = event.keyCode;
    else return true;
    selected_text = '';
    if (document.selection) {
        var selection = document.selection.createRange();
        var selected_text = selection.text;
    }
    else if (document.getSelection) {
        var start = ctrl.selectionStart;
        var end = ctrl.selectionEnd;
        var selected_text = ctrl.value.substring(start, end);
    }
    //keycodes allowed but not in the beginning - space
    if ((keycode == 32) && (((ctrl.value).length == 0) || selected_text != "")) {
        return false;
    }
    // The Special Characters ':' not allowed in the beginning
    if ((keycode == 58) && (((e.value).length == 0) || selected_text != "")) {
        return false;
    }
    if ((keycode >= 65 && keycode <= 90) || (keycode >= 97 && keycode <= 122) || (keycode == 58) || (keycode == 32)) {
        return true;
    }
    if (keycode == 8 || keycode == 0) {
        return true;
    }
    else return false;
}
//Allow numbers with dot.
function chkDecNums(e, obj) {
    debugger;
    if (!e) e = window.event;
    var c = (window.event) ? e.keyCode : e.which;
    if (c == 46 && obj.value.indexOf(".") != -1) {
        return false;
    }
    if ((c >= 48 && c <= 57) || c == 0 || c == 8 || c == 46 || c == 13 || c == 9 || c == 8 || c == 9 || c == 13 || c == 0 || c > 60000 || c == 127 || c == 37 || c == 39 || c == 46)
        return true;
    else
        return false;
}
// Accepts only Numbers and Colon(:) without white spaces inbetween 
function chkColonNums(e, obj) {
    debugger;
    if (!e) e = window.event;
    var c = (window.event) ? e.keyCode : e.which;
    if (c == 58 && obj.value.indexOf(":") != -1) {
        return false;
    }
    if ((c >= 48 && c <= 57) || c == 0 || c == 8 || c == 58 || c == 13 || c == 9 || c == 8 || c == 9 || c == 13 || c == 0 || c > 60000 || c == 127 || c == 37 || c == 39 || c == 58)
        return true;
    else
        return false;
}
function AcceptTab(e) {
    debugger;
    if (!e) e = window.event;
    var c = (window.event) ? e.keyCode : e.which;
    if (c == 0) {
        return true;
    }
    else {
        return false;
    }
}
