亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

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

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

    1.通過PHP語句判斷 :

    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.通過JS語句判斷

    <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.通過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為必須填寫數(shù)據(jù)-->     </div> </body> </html>

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

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