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

        • 安龙县| 玛多县| 内丘县| 灌南县| 陆良县| 河津市| 民县| 奇台县| 安平县| 裕民县| 南川市| 罗城| 绥滨县| 辽阳县| 安多县| 泰安市| 类乌齐县| 塔河县| 汪清县| 如东县| 敦煌市| 浦城县| 株洲市| 嘉兴市| 合阳县| 克东县| 东辽县| 辰溪县| 无极县| 沂南县| 博湖县| 隆化县| 安顺市| 罗甸县| 启东市| 夏津县| 建阳市| 搜索| 容城县| 龙山县| 大悟县|