I want to validate the passcode input field exclude special characters. Basically i just want to allow letters or numbers for some reason is not detecting characters like `, ´. ç, etc.
$('#passcode').on('keypress', function(e) {
var key = String.fromCharCode(!e.charCode ? e.which : e.charCode);
if (!/^[A-Z0-9]+$/i.test(key)) {
e.preventDefault();
}
})
Here is a fiddle: https://jsfiddle.net/gb5kc12z/
Try with % or ´, ç, `