How to Type only selective text in a Text Field/Box
We can Disable some characters from being written in a text field by using below functions
with JQuery
$("input").keypress( function(e)
{ var chr = String.fromCharCode(e.which);
if ("12345NOABC".indexOf(chr) < 0)
return false;
});
without JQuery
document.getElementById("foo").onkeypress = function(e)
{ var chr = String.fromCharCode(e.which);
if ("12345NOABC".indexOf(chr) < 0)
return false;
};
with JQuery
$("input").keypress( function(e)
{ var chr = String.fromCharCode(e.which);
if ("12345NOABC".indexOf(chr) < 0)
return false;
});
without JQuery
document.getElementById("foo").onkeypress = function(e)
{ var chr = String.fromCharCode(e.which);
if ("12345NOABC".indexOf(chr) < 0)
return false;
};
0 comments :
Feel free to leave comment if you like above widget, have any questions or just say Hi! :)