jQuery regex inputmask在IE 7中不起作用

杰森

我正在使用来自https://github.com/RobinHerbots/jquery.inputmask的jQuery inputmask,在Firefox,Chrome或IE 8+中没有问题。

但是,当我使用以下正则表达式输入掩码时,IE 7仅显示数据源中的第一个字符。我知道数据存在,因为如果我将文档模式从IE 7标准切换到IE 8标准或更高版本,则数据将立即可见。

有什么办法让正则表达式输入掩码显示IE 7中的所有数据?

$(".alpha").inputmask('Regex', { regex: "[a-zA-Z ]+" }); // Limits entry to letters and space character
$(".name").inputmask('Regex', { regex: "[a-zA-Z-`' ]+" }); // Limits entry to letters, -, `, ' and space character 
$(".alphanumeric").inputmask('Regex', { regex: "[a-zA-Z0-9 ]+" }); // Limits entry to letters, numbers and space character
杰森

看来,这与此处记录的IE 7前瞻错误有关。http: //blog.stevenlevithan.com/archives/regex-lookahead-bug更改上述正则表达式可以解决此问题(用{n,m}代替+)

// Due to lookahead bug in IE 7, used {n,m} instead of just +
$(".alpha").inputmask('Regex', { regex: "[a-zA-Z ]{1,50}" }); // Limits entry to letters and space character
$(".name").inputmask('Regex', { regex: "[a-zA-Z-`' ]{1,50}" }); // Limits entry to letters, -, `, ' and space character 
$(".alphanumeric").inputmask('Regex', { regex: "[a-zA-Z0-9 ]{1,50}" }); // Limits entry to letters, numbers and space character

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章