DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> PassWord輸入框代碼分享
PassWord輸入框代碼分享
編輯:關於JavaScript     

廢話不多說,直接給大家上干貨了,寫的不好歡迎提出意見。

具體代碼如下所示:

function hiddenPass(event)
{ 
var password0 = document.getElementById("password0"); 
var password1 = document.getElementById("password1"); 
if (event.keyCode == 13)
{ 
} 
var keycode; 
if (window.event) 
{ // IE 
keycode = event.keyCode 
} else if (event.which) 
{ // Netscape/Firefox/Opera 
keycode = event.which 
} 
var keychar = String.fromCharCode(keycode); 
password1.value = password1.value + keychar; 
password1.value = password1.value.substring(0,
password0.length);}function clearPass()
{ 
$("#password0").val(""); 
$("#password1").val("");
}
<li class="ba">
<label>密 碼:</label> 
<input type="text" id="password0" 
onfocus="javascript:clearPass();" 
onkeyup="this.value=this.value.replace(/./g,'*')" 
onkeypress="javascript:hiddenPass(event);"/> 
<input type="hidden" id="password1" name="password1"/>
</li>

以上代碼內容是小編給大家分享的PassWord輸入框代碼,希望對大家有所幫助!

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved