Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个电话号码字段的正则表达式模式,它允许用户输入 10 个数字或 0。我已经对其进行了测试并确认它可以在 Google Chrome、Internet Explorer、Firefox、Opera 和 safari 中运行,但由于某种原因它不是在 Netscape Navigator 9 中工作。非常感谢任何帮助。
谢谢
pattern="^[0-9]{10}$|^[0-9]{0}$"
新趋势是不检测特定浏览器,而是支持您需要的功能;在这种情况下,“模式”。
var el = document.createElement('input'); var isPatternSupported = (el.pattern === undefined); alert(isPatternSupported); // Displays `false` for NN9 and `true` for modern browsers