I've the following jquery function which avoid typing "1" in the input text:
<input id="myId" style="width:50%;" value="0" type="text">
$("#myId").keypress(function(e) {
var x=e.charCode;
if (x == '49'){
e.preventDefault();
}
});
This is the jsfiddle
which is not working on IE8. Where is my error? Thanks in advance!
EDIT JAVASCRIPT VERSION
<input id="myId" style="width:50%;" value="0" type="text" onkeypress="javascript:checkNumber(event);"/>
function checkNumber(event) {
var x=e.which;
if (x == 49){
event.preventDefault();
}
}