Netscape Navigator 9 中的正则表达式
Regex in Netscape Navigator 9
我有一个电话号码字段的正则表达式模式,它允许用户输入 10 个数字或 0。我已经对其进行了测试并确认它在 Google Chrome、Internet Explorer 中工作, Firefox, Opera 和 safari 但由于某些原因它不能在 Netscape Navigator 9 中工作。非常感谢任何帮助。
谢谢
pattern="^[0-9]{10}$|^[0-9]{0}$"
新趋势是不检测特定浏览器,而是支持您需要的功能;在这种情况下 "pattern".
var el = document.createElement('input');
var isPatternSupported = (el.pattern === undefined);
alert(isPatternSupported); // Displays `false` for NN9 and `true` for modern browsers
我有一个电话号码字段的正则表达式模式,它允许用户输入 10 个数字或 0。我已经对其进行了测试并确认它在 Google Chrome、Internet Explorer 中工作, Firefox, Opera 和 safari 但由于某些原因它不能在 Netscape Navigator 9 中工作。非常感谢任何帮助。
谢谢
pattern="^[0-9]{10}$|^[0-9]{0}$"
新趋势是不检测特定浏览器,而是支持您需要的功能;在这种情况下 "pattern".
var el = document.createElement('input');
var isPatternSupported = (el.pattern === undefined);
alert(isPatternSupported); // Displays `false` for NN9 and `true` for modern browsers