光标焦点未进入密码字段。
我使用下面的代码将输入文本字段交换到焦点密码区域。
<input type="text" name="password" id="password" onblur="ChangeToTextField(); if (this.value == '') {this.value = 'password';}" onfocus="ChangeToPassField(); if (this.value == 'password') { this.value = '';}else { this.value; }" value="password" style="width:230px; height:25px; margin-left:5px; background:none; border:0px;" />
<script type="text/javascript">
function ChangeToPassField() {
document.getElementById('password').type="password";
var input = document.getElementById('password');
input.focus();
}
function ChangeToTextField() {
if(document.getElementById('password').value=="" || document.getElementById('password').value == "password" )
{
//alert("hai");
document.getElementById('password').type="text";
document.getElementById('password').value="password";
}
}
</script>
如果我单击密码字段,光标不会在密码字段中闪烁。如何在密码字段中显示光标指针?...
I am using the below code for swap an input text field to a password area on focus.
<input type="text" name="password" id="password" onblur="ChangeToTextField(); if (this.value == '') {this.value = 'password';}" onfocus="ChangeToPassField(); if (this.value == 'password') { this.value = '';}else { this.value; }" value="password" style="width:230px; height:25px; margin-left:5px; background:none; border:0px;" />
<script type="text/javascript">
function ChangeToPassField() {
document.getElementById('password').type="password";
var input = document.getElementById('password');
input.focus();
}
function ChangeToTextField() {
if(document.getElementById('password').value=="" || document.getElementById('password').value == "password" )
{
//alert("hai");
document.getElementById('password').type="text";
document.getElementById('password').value="password";
}
}
</script>
If i click in password field the cursor is not blinking in the password field. How can i display cursor pointer in the password field?...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 HTML 5
placeholder
属性怎么样? (请记住,它并非在所有地方都有效)jsfiddle: http://jsfiddle.net/ndduP/
否则,这是您正在尝试执行的操作的尝试(请记住,有些人可能会关闭 javascript,从安全/隐私的角度来看,这会导致此问题)
jsfiddle: http://jsfiddle.net/utEVx/
What about using the HTML 5
placeholder
attribute? (keep in mind it won't work everywhere)jsfiddle: http://jsfiddle.net/ndduP/
Otherwise, here is an attempt at what you are trying to do (keep in mind some people could potentially have javascript turned off making this problematic from a security/privacy standpoint)
jsfiddle: http://jsfiddle.net/utEVx/