怎樣在密碼表單已經(jīng)輸入的狀態(tài)下不要彈出confirm對(duì)話框
//測(cè)試onmouseover事件,彈出confirm確認(rèn)對(duì)話框
var psw1=document.getElementById(psw1);
function showConfirm(){
if(psw1==null){
var showConfirm=confirm("請(qǐng)?jiān)诿艽a表單中輸入密碼!");
}
}
這樣子還是會(huì)彈出的。
//測(cè)試onmouseover事件,彈出confirm確認(rèn)對(duì)話框
var psw1=document.getElementById(psw1);
function showConfirm(){
if(psw1==null){
var showConfirm=confirm("請(qǐng)?jiān)诿艽a表單中輸入密碼!");
}
}
這樣子還是會(huì)彈出的。
2017-03-15
舉報(bào)
2017-09-20
二個(gè)問題:1.var psw1=document.getElementById(psw1?? 改為?? var psw1=document.getElementById("psw1").value放在函數(shù)中;2.if(psw1==null)?? 改為 if(psw1=="");
2017-08-10
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> 鼠標(biāo)經(jīng)過事件 </title>
<script type="text/javascript">
? ??
function message(){var psw1=document.getElementById("psw2");?
if(psw1==null){
confirm("請(qǐng)?jiān)诿艽a表單中輸入密碼!");
}else{
alert("密碼輸入成功!");
}
}
</script>
</head>
<body>
<form>
密碼:<input name="password" type="password" id="psw2"/>
<input name="確定" type="button" value="確定" onmouseover="message()"/>
</form>
</body>
</html>
2017-06-28
同學(xué) ?var psw1=document.getElementById(psw1);
ById(); ?獲取的ID是要用""引起來的,才能找到ID;
還有<input type="password" id="pw" name="password"? >
密碼框的內(nèi)容的屬性為 ?value 值 ?,必須判斷value值是否為空 ?才可以;
例如 ::<input type="password" id="pw" name="password" ?value=“12345”?>
密碼框里的內(nèi)容為 12345 ? 不過都是看不見的點(diǎn) ?你可以再做做看
2017-03-19
<!DOCTYPE HTML>
<html>
?<head>
??
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
??
<title> 鼠標(biāo)經(jīng)過事件 </title>
??
<script type="text/javascript">
???//等待頁面全部加載了再加載函數(shù),因?yàn)橄燃虞djs代碼的話,會(huì)找不到id為pw的元素
???$(document).ready(function()
???{
?????message();
???});
???function message()
???{
?????
????var pw = document.getElementById("pw").value;
????//輸入了密碼什么都沒做,沒輸入密碼的話進(jìn)行提示
????if(pw == null || pw=="")
?????confirm("請(qǐng)輸入密碼后,再單擊確定!");
???}
??
</script>
?</head>
?
<body>
??
<form>
???
密碼:<input type="password" id="pw" name="password"? >
???<input type="button" name="確定"? value="確定" onmouseover="message()"/>
??</form>
?</body>
</html>
2017-03-17
var psw1=document.getElementById("psw1");?? //注意:id要加上""
function showConfirm(){
if(psw1==null){
confirm("請(qǐng)?jiān)诿艽a表單中輸入密碼!");
}else{
alert("密碼輸入成功!");
}
}
//這樣應(yīng)該就可以了
2017-03-15
var aa=document.getElementById("ppp");
if(aa==null)
?confirm("請(qǐng)輸入密碼后,再單擊確定!");?
這樣就可以了