How to block or restrict special characters from input fields with jquery?
on
Get link
Facebook
X
Pinterest
Email
Other Apps
jQuery("#input_id").keypress(function(event) {
var character = String.fromCharCode(event.keyCode);
return isValid(character);
});
function isValid(str) {
return !/[~`!@#$%\^&*()+=\-\[\]\\';,/{}|\\":<>\?]/g.test(str);
}
Comments
Post a Comment