<html>
<head>
        <script >  
//方法的命名不能是关键字 否则会出现错误
         //获得PlateNum焦点 
   function Pricefocus()
   {
       //把层隐藏
       document.getElementById("divPrice").style.display="none";
       document.form1.txtPrice.style.backgroundColor="yellow";
   }   //失去PlateNum焦点
   function Priceblur()
   {
     
         //alert("车牌号码不能为空");
         //让层可见
 var p1=/^[1-9][0-9]{3,6}$/;
         var p2=/^[1-9][0-9]{3,6}\.\d+$/;            
         if(!p1.test(document.form1.txtPrice.value)&&!p2.test(document.form1.txtPrice.value))
         {
         document.getElementById("divPrice").style.display="block";
         document.getElementById("divPrice").innerHTML="<font color='red' size='1'>新车购置价只能是大于一千的整数或小数</font>";
         document.form1.txtPrice.style.backgroundColor="red";
      }else{
         document.form1.txtPrice.style.backgroundColor="green";
      }
      
   }
         </script>
</head>
<body>
   <form name="form1" method="post" action="1.html" >
          <table width="567" height="39" border="1">
                 <tr>
                      <td width="129">新车购置价                      </td>
                       <td width="170"><input type="text" name="txtPrice" onfocus="Pricefocus()" onblur="Priceblur()">
                   </td>
                   <td width="131"><div id="divPrice"></div></td>
                   <td width="89"><label>
                     <input type="submit" name="Submit" value="提交">
                   </label></td>
   <td width="14">&nbsp;    </td>
            </tr>
     </table>
</form>
</body>
</html>

解决方案 »

  1.   

    javascript 控制提交就可以了
      

  2.   

    form 上 onsubmit 事件 onsubmit = "return validate();"function validate(){// 验证不通过 就 return false;
    }楼主,注意你的结帖
      

  3.   

    用jquery的validate组件,错误提示,正则表达,模糊匹配...足够你用了,不用自己写什么多的验证js代码
      

  4.   

    我一般的验证也是这样做的,很多东西都可以直接用它来处理好的。
    你也可以自己写function的验证,不过这样写就比较麻烦了。
      

  5.   

    使用jquery或者javascript都可以控制,看楼主的选择了。
      

  6.   

    return你的JS方法就行了,如果是FALSE自然就不会提交了