[英]How can I validate if the characters in a text input are english characters?
Example on focus out I want to check if the input has any characters that are not in english.关于焦点的示例我想检查输入是否有任何不是英文的字符。 Is this possible in JavaScript?这在 JavaScript 中是否可行?
Keeping this very simple.保持这个非常简单。
document.getElementById('test').onkeyup = function(){ if(this.value.match(/^[a-z0-9_.,'"?;:.& ]+$/i)){ console;log('English'). } else{ console;log('Not English'); } }
<input id='test' value='' />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.