比如,,在文本区输入0之后, 点一个NEXT按钮, 会有ALERT提醒不能输入零,点击ok之后,不改变值,再点击NEXT按钮,就能通过了,如何做啊?!  谢谢!!! 

解决方案 »

  1.   

    <input type="text" value="0" id="chk0" />
    <input type="button" value="next" onclick="if (document.getElementById('chk0').value==0) {alert('输入值不能为0!');this.onclick='';return false;}"
      

  2.   

    <html>
    <head>
    <script>
    var f=true;
    window.onload = (function(){ 
    txt1.onkeydown=function(){
    f=(f&&event.keyCode!=48);
    };
    btn1.onclick=function(){
    if(f)
    alert("correct");
    else{
    alert("fault");
    f=true;
    }
    };
    });</script>
    </head>
    <body>
    <input type=button id=btn1>
    <input type=text id=txt1>
    </body>
    </html>
      

  3.   

    加个hidden进去,第一次给它赋值1,NEXT按钮每次点击事件都判断hidden的值。
    if(hidden.value=="1")
    {
       //pass
    }
    else{//stop}
      

  4.   

    <script language="javascript">
    var x=0
    function check(){
    if(document.getElementById("text").value==0 && x==0){
    alert("输入值不能为零!")
    x=x+1
    return false
    }
    else
    {
    return true;
    }}
    </script>