My JavaScript is quite rusty so any help with this would be great. I have a requirement to detect non printable characters (control characters like SOH, BS etc) as well exte
You have to assign a pattern (instead of string) into isNonAscii variable, then use test() to check if it matches. test() returns true or false.
$(document).ready(function() {
$('.jsTextArea').blur(function() {
var pattern = /[^\000-\031]+/gi;
var val = $(this).val();
if (pattern.test(val)) {
alert("It matched");
}
else {
alert("It did NOT match");
}
});
});
Check jsFiddle