日期:2014-05-16  浏览次数:20490 次

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