`
zgw06629
  • 浏览: 30024 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

js 正则表达式 /g 火狐下bug

阅读更多
<html>
<body>
<script type="text/javascript">
function isNumeric(strValue)
{
    return /^\d*$/g.test(strValue);
}
function isNumeric1(strValue)
{
    return /^\d*$/.test(strValue);
}
strValue = '1000'
document.writeln(isNumeric(strValue)); // true
document.writeln(isNumeric(strValue)); // firefox: false;  IE:true
document.writeln('<br/>')
document.writeln(isNumeric1(strValue)); // true
document.writeln(isNumeric1(strValue)); // true
document.writeln('<br/>')
document.writeln(/^\d*$/g.test(strValue)); // true
document.writeln(/^\d*$/g.test(strValue));// true
</script>
</body>
</html>
原因分析见:http://www.jb51.net/article/18334.htm
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics