<input type="image" name="submit" src="img/zhuce.png"style="margin-left: 80px;"  onclick="return check();" />
想通过check方法验证再提交,结果自动提交了。我在check方法里加了return false,还是自动提交了?
<input type="image" name="submit" src="img/zhuce.png"style="margin-left: 80px;"  onclick="check();return false;" />这样能拦截提交,但是验证成功了也要被拦截。急求解决方法,新人分不多请笑纳input input  imageonclick提交check

解决方案 »

  1.   

    try this:onclick="if check() return true; else return false;" 
      

  2.   

    不行  还是直接提交了  我把javascript代码发上来再帮我看看吧  谢谢
    var message =""; 
    function check(){
     var name = document.getElementById("name").value;
     return checkIsNull(name,"message");
     
     }
     function checkIsNull(value,messageSpan){
     var b = "";
     message="";
     var redata = /\t/;
     if(value.length==0 || value.value==""||redata.test(value)==true){
    message = "不能为空";
    b=false;
     }else {
    b=true;
    }
     document.getElementById(messageSpan).innerHTML = message;
     return b;
     
     }
      

  3.   

    <input type="image" name="submit" src="img/zhuce.png"style="margin-left: 80px;"  onclick="return check();" />