<script language="JavaScript">function _0009(str)
{
    return /^(0(?=\.|$)|[1-9])\d*(?:\.[05])?$/.test(str);
}
document.writeln("<br>0=" + _0009("0"));
document.writeln("<br>01=" + _0009("01"));
document.writeln("<br>10=" + _0009("10"));
document.writeln("<br>10.=" + _0009("10."));
document.writeln("<br>10.2=" + _0009("10.2"));
document.writeln("<br>10.5=" + _0009("10.5"));
document.writeln("<br>10.0=" + _0009("10.0"));
document.writeln("<br>0.5=" + _0009("0.5"));
document.writeln("<br>10.55=" + _0009("10.55"));
</script>

解决方案 »

  1.   

    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    ※以下是引用楼主 dzpkhas(仲平) 在2007-06-15 14:24:38 的发言:
    ──────────────────────────────────────────
    果然是高手,正解
    请问不用正则表达式,能解决类似的问题吗
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
    function _0009(str)
    {
        return !isNaN(str) && !(str * 10 % 5);
    }