正则:求个去0的正则
一个文本框里的可以是0,但要排除01234这样的情况,还要排除0000.0000和0001.0000,或者...可能还有我没考虑到的,大家能提醒最好.总之就是要让这个文本框里的数据变规范.
补充下:是不是用JS来的更方便一点呢?放到个数组中在判断?请高手给指点下
------解决方案-------------------- <input type= "text " id= "jia " value= "00123.044000 "> <br>
<input type= "button " onclick= "f(); " value= "check ">
<script language= "javascript ">
function f(){
var jia = document.getElementById( "jia ");
jia.value = parseFloat(jia.value);
}
</script>
------解决方案-------------------- <body>
<script language= "JavaScript ">
function check(str)
{
var pattern = /^(0|[1-9]\d*)(\.(0*)?[1-9]\d*)?$/i;
if (pattern.test(str))
alert( "ok ");
else
alert( "no ")
}
</script>
<input type= "text " id= "txt " value= " ">
<input type= "button " onclick= "check(txt.value) " value= "Check ">
</body>