DòngThay đổi kiểu <input> trong IE với JavaScript
<input type="text" name="passwordLogin" value="Password" onfocus="if(this.value=='Password'){this.value=''; this.type='password'};" onblur="if(this.value==''){this.value='Password'; this.type='text'};" size="25" />
công trình trong tất cả các trình duyệt web IE trừ ... Làm thế nào tôi có thể sửa chữa nó cho IE?
Ok thực hiện một số thay đổi để vẫn có một lỗi
Tôi muốn nó hoạt động như thế này như đây
<input type="text" name="usernameLogin" value="Email" onfocus="if(this.value=='Email'){this.value=''};" onblur="if(this.value==''){this.value='Email'};" size="25" />
nếu tôi không nhập bất cứ điều gì nó sẽ đưa các giá trị trở lại
Vì vậy, tôi đã thử điều này
<td colspan="2" id="passwordLoginTd">
<input id="passwordLoginInput1" type="text" name="passwordLogin" value="Password" onfocus="passwordFocus()" size="25" />
<input id="passwordLoginInput2" style="display: none;" type="password" name="passwordLogin" value="" onblur="passwordBlur()" size="25" />
</td>
<script type="text/javascript">
//<![CDATA[
passwordElement1 = document.getElementById('passwordLoginInput1');
passwordElement2 = document.getElementById('passwordLoginInput2');
function passwordFocus() {
passwordElement1.style.display = "none";
passwordElement2.style.display = "inline";
passwordElement2.focus();
}
function passwordBlur() {
if(passwordElement2.value=='') {
passwordElement2.style.display = "none";
passwordElement1.style.display = "inline";
passwordElement1.focus();
}
}
//]]>
</script>
vì bạn có thể thấy làm mờ không hoạt động = [
ok cuối cùng đã nhận nó nhờ vào sự giúp đỡ cần thiết để loại bỏ
passwordElement1.focus();
dang thats những gì tôi đã có trước và tôi đã nói với nó là sai = [grr = [ – MrEnder
Hoạt động trong IE9 trở lên. – Barney