我正在寻找一个正则表达式,或者返回 TRUE/FALSE 的简单函数,它检测非 ASCII Unicode 字符的存在,用于我的 $("form").validate({
调用。基本上,如果用户输入任何 unicode 字符,我希望验证失败。我希望允许所有标准的、SQL-VARCHAR 可接受的字符。
最佳答案
你可以只使用这个正则表达式:
var re = /[^\x00-\x7f]/;
然后将其用作:
var invalid = re.test(name);
// true if there is any character beyond ASCII (128) is present
关于javascript - Validate.JS - 禁止使用非 ASCII Unicode 字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28439287/