简体   繁体   English

Netscape Navigator 9中的正则表达式

[英]Regex in Netscape Navigator 9

I have a regex pattern for a telephone number field which allows the user to enter either 10 numbers or 0. I have tested it and confirmed it is working in Google Chrome, Internet Explorer, Firefox, Opera and safari but for some reason it is not working in Netscape Navigator 9. Any help is very much appreciated. 我在电话号码字段中有一个正则表达式模式,允许用户输入10个数字或0个数字。我已经对其进行了测试,并确认它可以在Google Chrome,Internet Explorer,Firefox,Opera和safari中运行,但由于某些原因,它不能运行在Netscape Navigator 9中工作。非常感谢您的帮助。

Thank you 谢谢

pattern="^[0-9]{10}$|^[0-9]{0}$"

The new trend is to not detect specific browsers, but rather support for the feature you need; 新趋势是不检测特定的浏览器,而是支持所需的功能。 in this case "pattern". 在这种情况下为“模式”。

var el = document.createElement('input');
var isPatternSupported = (el.pattern === undefined);

alert(isPatternSupported); // Displays `false` for NN9 and `true` for modern browsers

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM