I have an HTML input that I want to sanitize. I want users to enter everything except some characters. I don't know what those characters are, but users somehow enter them by copying and pasting. Sublime Text shows them as STX, SOH and so on. I don't know if you can see them, but here they are:" ". I don't want to list every character that I accept, nor I can list these STX, SOH characters. I can't use A-Za-z, because I also want users to enter characters like 'ç'.
How can I achieve this easily?
Here's a part of the -unfinished- code that I found on here:
function validate(evt) {
var theEvent = evt || window.event;
var key = theEvent.keyCode || theEvent.which;
key = String.fromCharCode( key );
// var regex = /[0-9]|\./;
var regex = /[a-zA-Z0-9\!\'\+\-\&\\\/\(\)\?\@\#\$\%\^\*\_\|]+/;
if( !regex.test(key) ) {
theEvent.returnValue = false;
theEvent.preventDefault();
}
}
Thank you very much in advance