month.replace(/(10|3|5|7|8|1|12)/g,'')
它匹配了1就跳出来了,1和10换个位置

解决方案 »

  1.   

    10和12要放在前面
    month="10"
    month=month.replace(/(12|10|1|3|5|7|8)/g,"")
    alert(month)
      

  2.   

    按你的写法1和10都满足要求自然就直接把1替换掉了month=0
    <script type="text/javascript">
         var month="10";
         alert(month.replace(/(10|12|1|3|5|7|8)/g,'')=="");
    </script>
      

  3.   

    var month = '10'
    //alert(month.replace(/(1|3|5|7|8|10|12)/,''))
    alert(month.replace(/(10|3|5|7|8|12|1)/,'') == '')中间的你可以看看alert出什么东西
      

  4.   

    month="11"  怎么办,也在这个里面
      

  5.   

    10,11,12要放在前面 
    month="11" 
    month=month.replace(/(12|11|10|1|3|5|7|8)/g,"") 
    alert(month)