第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

如何判斷密碼框是否為空?

密碼:<input name="password" type="password" >

正在回答

3 回答

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title> 鼠標(biāo)經(jīng)過(guò)事件 </title>

<script type="text/javascript">

? ? function inputTEXT(){

? ? ? ? var x=document.getElementById("text").value;

? ? ? ? if(x==""){

? ? ? confirm("請(qǐng)輸入密碼后,再單擊確定!");

? ? ? }

? ? ? else{

? ? ? ? ? alert("提交成功!");

? ? ? }

? ? }

</script>

</head>

<body>

<form>

密碼:<input name="password" type="password" id="text"><br> <br>?

<input name="確定" type="button" value="確定" onclick="inputTEXT()"/>

</form>

</body>

</html>


0 回復(fù) 有任何疑惑可以回復(fù)我~
<script?type="text/javascript">
??//button?按鈕,結(jié)合onclick事件,驗(yàn)證和提交表單
??function?checkForm(){????????//判斷用戶名是否為空
????????if(document.form1.username.value==""){
????????????????window.alert("用戶名不能為空");
????????}else?if(document.form1.username.value.length<5?||?document.form1.username.value.length>20){
????????????window.alert("用戶名長(zhǎng)度必須介于5-50個(gè)字符之間!");
????????}else{????????????//使用form對(duì)象的submit()方法,實(shí)現(xiàn)提交。????????????document.form1.submit();????????
????????}
??}?</script>
?</head>
?<body>
??<form?name="form1"?method="get"?action="login.php">
??用戶名:<input?type="text"?name="username"?/>
??密碼:<input?type="password"?name="userpwd"?/>
??<input?type="button"?value="提交表單"?onclick="checkForm()"?/>
??</form>
?</body>


0 回復(fù) 有任何疑惑可以回復(fù)我~

<script type="text/javascript">
??? function message(){
????? var pwd=document.getElementById("password").value;
????? if(!pwd){
????? confirm("請(qǐng)輸入密碼后,再單擊確定!");
????? }
????? else{
????????? alert("succeed login in");
????? }
?????? ?
??? }
</script>
</head>
<body>
<form>
密碼:<input name="password" type="password" id="password">
<input name="確定" type="button" value="確定" onclick="message()"/>
</form>
</body>
</html>


懂了,想取密碼框的值,可以先給控件設(shè)置ID,通過(guò)讀取ID的值來(lái)查看密碼框的值。

分享給和我一樣初學(xué)的小伙伴


6 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

如何判斷密碼框是否為空?

我要回答 關(guān)注問題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)