I need to stop the users to enter text using alphabet different from the Latin one (aka english).
I am using the following function based on a regex but I have some issues:
- The validation fails if the input is empty
- The validation pass if the input is mixed for example
aaaaффффф
I solve the first point using a simple if
anyway it would be nice if the regex take care of this case too
The second point is what I care more.
function validate_latin(v){
var regex = new RegExp("[\u0000-\u007F\u0080-\u00FF]");
if (v != '') {
return regex.test(v);
}
return true;
}
p.s. I googled and found other similar question but none is complete or cover this sceniario