关于表单中提示性的文字
<script>
function a()
{
var username=frmRegister.txtUserName.value;
if(username="密码")
{username=""}
}
function b(){
var username=frmRegister.txtUserName.value;
if(username="")
{username="密码"}
}
</script>
<body>
<input type="text" name="txtUserName" id="txtUserName" size="12" class="required" onfocus="a()" onblur="b()" value="密码" style="color:gray"/>
</body>
没办法实现,怎么回事?
js
css
html
网页
------解决方案--------------------
<script>
function a()
{
var username=frmRegister.txtUserName;
if(username.value=="xxx")
{
username.value=""
}
}
function b(){
var username=frmRegister.txtUserName;
if(username.value=="")
{
username.value="xxx";
}
}
</script>
<input type="text" name="txtUserName" id="txtUserName" size="12" class="required" onfocus="a()" onblur="b()" value="xxx" style="color:gray" />
------解决方案--------------------楼主可以试试HTML5的新属性placeholder
<input type="text" name="txtUserName" id="txtUserName" size="12" class="required" placeholder="密码" style="color:gray"/>