<input type="text" name="ss" value="Sou"><input type="submit" name="bt" value="SouSuo">
点击提交时,如果输入框里是默认值的话就跳到指定的页面,否则正常提交,怎么写

解决方案 »

  1.   

    if(value=="Sou"){window.location=''}else{submit();}
      

  2.   

    为什么我在外面加个<form>标签就不能用了
      

  3.   

    <form action="test.asp" onsubmit="return check(this)">
    <input type="text" name="ss" value="Sou">
    <input type="submit" name="bt" value="SouSuo">
    </form>
    <script type="text/javascript">
    function check(f){
    if( f.ss.value == f.ss.defaultValue ){
    location.href = 'http://baidu.com/'
    return false;
    }
    }
    </script>
      

  4.   

    <!DOCTYPE HTML>
    <html>
     <head>
      <title> New Document </title>
      <meta charset="uft-8">
     </head>
    <script>
     function ceshi(){
      var el=document.getElementById('Sou');
      if(el.value == "Sou")
    {
      window.location='http://www.baidu.com'
      }else{
    submit();
      }
     }
    </script>
     <body>
    <form>
      <input style="text" id="Sou" name="ss" value="Sou"><input type="submit" value="SouSuo" onclick="ceshi()">
    </form>
     </body>
    </html>
      

  5.   

    <!DOCTYPE HTML>
    <html>
     <head>
      <title> New Document </title>
      <meta charset="uft-8">
     </head>
    <script>
     function ceshi(e){
     e = e || window.event;
     // 阻止submit的默认行为
    e.returnValue = false;
    if(e.preventDefault){
    e.preventDefault();
    }var el=document.getElementById('Sou');
    if(el.value == "Sou")
    {
    window.location = 'http://www.baidu.com'
    }else{
    document.getElementById('frm').submit();
    }
    }
    </script>
     <body>
    <form id="frm" action="http://g.cn">
      <input style="text" id="Sou" name="ss" value="Sou"><input type="submit" value="SouSuo" onclick="ceshi()">
    </form>
     </body>
    </html>
      

  6.   

    回6#
    那只狐狸只認得Google。