欧美亚洲中文,在线国自产视频,欧洲一区在线观看视频,亚洲综合中文字幕在线观看

      1. <dfn id="rfwes"></dfn>
          <object id="rfwes"></object>
        1. 站長(zhǎng)資訊網(wǎng)
          最全最豐富的資訊網(wǎng)站

          如何判斷html中文本框內(nèi)容是否為空

          如何判斷html中文本框內(nèi)容是否為空

          1.通過(guò)PHP語(yǔ)句判斷 :

          html中內(nèi)容:

          <form action="submit.php" method="post"> <textarea name="text"></textarea> </form>

          php中內(nèi)容:

          //submit.php <?php if(isset($_POST['text']) && strlen(trim($_POST['text']))>0) echo '不空'; else echo '空 '; ?>

          2.通過(guò)JS語(yǔ)句判斷

          <html> <head> <title>JS判斷input是否為空</title> <script>function op(){ 	if(document.getElementById("ip").value==""){ 		alert("input為空"); 	}else{ 		alert(document.getElementById("ip").value); 	} 	} </script> </head> <body>     <input id="ip" onblur="op()" value="JS"/> </body> </html>

          3.通過(guò)required屬性判斷

          <html lang="en"> <head>     <meta charset="UTF-8">     <meta http-equiv="X-UA-Compatible" content="IE=edge">     <meta name="viewport" content="width=device-width, initial-scale=1.0">     <title>表單</title> </head> <body>     <form action="" style="display: grid;" method="POST">           <div>          <label for="username">賬號(hào):</label>         <input type="text" id="username" required>                                   <!--required為必須填寫(xiě)數(shù)據(jù)-->     </div> </body> </html>

          推薦:《html知識(shí)》

          贊(0)
          分享到: 更多 (0)
          網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)