<strike id="3tkic"><sup id="3tkic"></sup></strike>

  1. <ul id="3tkic"></ul>
      <b id="3tkic"><legend id="3tkic"></legend></b>
      <b id="3tkic"><meter id="3tkic"></meter></b>

    • <strike id="3tkic"></strike>

      <blockquote id="3tkic"></blockquote>

    • 亚洲AV无码国产在丝袜线观看_亚洲第一页A∨在线_亚洲国产人成在线观看69网站_无码日韩人妻AV一区免费l

      form表單提交和阻止

      2016/11/29 8:37:13   閱讀:1702    發(fā)布者:1702
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
      > <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> new document </title> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <style type="text/css"></style> <script type="text/javascript"> //實例:submit按鈕,結合onsubmit事件,驗證和提交表單 function checkForm(){ //判斷用戶名和密碼是否為空 if(document.form1.username.value==""){ window.alert("用戶名不能為空"); return false; }else if(document.form1.username.value.length<5 ||
      document.form1.username.value.length
      >20){ window.alert("用戶名在5-20位"); return false; }else if(document.form1.userpwd.value==""){ window.alert("密碼不能為空"); return false; }else if(document.form1.userpwd.value.length<5 ||
      document.form1.userpwd.value.length
      >20){ window.alert("密碼必須在5-20位"); return false; } } </script> </head> <body> <form name="form1" method="get" action="login.php" onsubmit="return checkForm()"> 用戶名:<input type="text" name="username" /> 密碼:<input type="password" name="userpwd" /> <input type="submit" value="提交表單" /> </form> //單機以下的鏈接,不會跳轉網(wǎng)址,因為默認動作被阻止了 <a href="http://www.itcast.cn" onclick="return false">北京交通網(wǎng)</a> </body> </html>

      onsubmit="return checkForm()" 加return是事件返回事件,當返回值為false的時候會阻止表單提交。

      事件返回值:

      事件的返回值,會影響事件的默認動作。

      如果事件的返回值為false,則阻止默認動作執(zhí)行。

      如果事件返回值為ture或空,則默認動作執(zhí)行。

      如果事件沒有任何返回值,則默認動作執(zhí)行。

      受影響的事件有兩個:onclick、onsubmit

      其他事件的返回值,不會影響默認動作。

      onclick的返回值也會組織submit的提交。

      亚洲AV无码国产在丝袜线观看_亚洲第一页A∨在线_亚洲国产人成在线观看69网站_无码日韩人妻AV一区免费l
      <strike id="3tkic"><sup id="3tkic"></sup></strike>

      1. <ul id="3tkic"></ul>
          <b id="3tkic"><legend id="3tkic"></legend></b>
          <b id="3tkic"><meter id="3tkic"></meter></b>

        • <strike id="3tkic"></strike>

          <blockquote id="3tkic"></blockquote>

        • 乡城县| 呼伦贝尔市| 敦化市| 肇庆市| 金阳县| 清徐县| 井冈山市| 大英县| 汉中市| 长丰县| 延津县| 偏关县| 托里县| 汉源县| 建宁县| 太仆寺旗| 大兴区| 阿鲁科尔沁旗| 宾阳县| 库车县| 务川| 迁西县| 昌图县| 额济纳旗| 景泰县| 海口市| 禄丰县| 乐昌市| 平舆县| 化德县| 林州市| 龙里县| 睢宁县| 阿勒泰市| 延吉市| 九台市| 锡林浩特市| 德惠市| 政和县| 鲁山县| 宜阳县|