Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 输入字段具有浏览器记住的初始值,但我不希望它们出现_Html_Input - Fatal编程技术网

Html 输入字段具有浏览器记住的初始值,但我不希望它们出现

Html 输入字段具有浏览器记住的初始值,但我不希望它们出现,html,input,Html,Input,我想对这个输入文本字段做两件事 <input type="text" value="email@abc.com" name="Email" id="Email" onblur="if (this.value == '') {this.value = 'email@abc.com';}" onfocus="if (this.value == 'email@abc.com') {this.value = '';}" /> 初始值设置为“email@abc.com“但我只想将文本

我想对这个输入文本字段做两件事

<input type="text" value="email@abc.com" name="Email" id="Email"
 onblur="if (this.value == '') {this.value = 'email@abc.com';}"
 onfocus="if (this.value == 'email@abc.com') {this.value = '';}" />

初始值设置为“email@abc.com“但我只想将文本颜色更改为灰色,前提是他们没有在文本字段中键入

<input type="text" value="email@abc.com" name="Email" id="Email"
 onblur="if (this.value == '') {this.value = 'email@abc.com';}"
 onfocus="if (this.value == 'email@abc.com') {this.value = '';}" />
我也有一个问题,不同的浏览器有下拉菜单的话,用户已经在其他网站的其他输入字段键入。如何清除浏览器生成的列表?


<input type="text" onblur="if(this.value==''){this.value='Enter your email address'};" onfocus="if(this.value=='Enter your email address'){this.value=''};" value="Enter your email address" size="10" alt="username" class="bt login_input" id="mod_login_username" name="username">
请参阅本网站


使用firebug有关自动填充,请查看

关于“水印”,我建议(如果你不反对jQuery的话)(但是如果你在谷歌上搜索“占位符”、“水印”和“html”(或者它们的任意组合),我相信会有很多选择。)


另一方面,我会将格式保存在一组
标记中,并保留标记本身。标记应该是标记;javascript应该单独补充,而不是与标记对齐)

可以在您已经拥有的事件处理程序中更改颜色,并调用
this.style.color=“grey”
如果您想要跨浏览器解决方案,但HTML5包含
占位符
属性,但目前还没有得到很好的支持

为了防止代码在事件处理程序中变得难以读取,我建议将事件处理程序放在


document.getElementById('Email')。onblur=function(){
如果(this.value==''){
这是我的价值观email@abc.com';
this.style.color=“灰色”;
}
否则{
this.style.color=“黑色”;
}
};
//等等。

要停止自动填充,请使用
()

,它不会改变颜色,也不会阻止浏览器创建previus输入值的下拉列表。