Within Script Block :
var specialKeys = new Array();
specialKeys.push(8); //Backspace
specialKeys.push(9); //Tab
specialKeys.push(46); //Delete
specialKeys.push(36); //Home
specialKeys.push(35); //End
specialKeys.push(37); //Left
specialKeys.push(39); //Right
function IsAlphaNumeric(e) {
var keyCode = e.keyCode == 0 ? e.charCode : e.keyCode;
var ret = ((keyCode >= 48 && keyCode <= 57) || (keyCode >= 65 && keyCode <= 90) || (keyCode >= 97 && keyCode <= 122) || (specialKeys.indexOf(e.keyCode) != -1 && e.charCode != e.keyCode));
if ($('#txtCode').val().length > 7)
ret= false;
if (!ret)
$("#errmsg").html("NO Symbol(s) & 8 Char").show().fadeOut("slow");
return ret;
}
where the HTML Like bellow :
<input id="txtCode" name="Code" class="/*easyui-validatebox*/ required form-control" required="true" style="width:100%" onkeypress="return IsAlphaNumeric(event);" ondrop="return false;" onpaste="return false;">
<span id="errmsg"></span>
--- on " onkeypress " event of that textbox that function filtered the input value & showing or inserted valied input . and it should not cross more than 8 char.
var specialKeys = new Array();
specialKeys.push(8); //Backspace
specialKeys.push(9); //Tab
specialKeys.push(46); //Delete
specialKeys.push(36); //Home
specialKeys.push(35); //End
specialKeys.push(37); //Left
specialKeys.push(39); //Right
function IsAlphaNumeric(e) {
var keyCode = e.keyCode == 0 ? e.charCode : e.keyCode;
var ret = ((keyCode >= 48 && keyCode <= 57) || (keyCode >= 65 && keyCode <= 90) || (keyCode >= 97 && keyCode <= 122) || (specialKeys.indexOf(e.keyCode) != -1 && e.charCode != e.keyCode));
if ($('#txtCode').val().length > 7)
ret= false;
if (!ret)
$("#errmsg").html("NO Symbol(s) & 8 Char").show().fadeOut("slow");
return ret;
}
where the HTML Like bellow :
<input id="txtCode" name="Code" class="/*easyui-validatebox*/ required form-control" required="true" style="width:100%" onkeypress="return IsAlphaNumeric(event);" ondrop="return false;" onpaste="return false;">
<span id="errmsg"></span>
--- on " onkeypress " event of that textbox that function filtered the input value & showing or inserted valied input . and it should not cross more than 8 char.

0 comments:
Post a Comment