<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>

        • 色达县| 崇文区| 阿鲁科尔沁旗| 湖州市| 镇远县| 同心县| 延长县| 德兴市| 突泉县| 双辽市| 开封县| 璧山县| 鄂托克旗| 应用必备| 宁河县| 博乐市| 房山区| 德化县| 马边| 惠东县| 炉霍县| 如皋市| 乌鲁木齐县| 西乌| 嘉祥县| 神池县| 黎平县| 新化县| 同德县| 依安县| 新民市| 图木舒克市| 渝北区| 东港市| 行唐县| 惠州市| 大足县| 广河县| 高陵县| 乌兰察布市| 页游|