清除文本框值并单击显示onblur [英] Clearing the textbox values onclick and displaying onblur
本文介绍了清除文本框值并单击显示onblur的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法清除文本框上的默认文本框值并在表单页面上显示多个文本框的onblur?
Is there a way to clear the default textbox value onclick on textbox and display onblur of multiple textboxes on form page?
推荐答案
function Clear1(str)
{
document.getElementById(str).value= "";
}
function Clear2(str2)
{
var aa1=document.getElementById(str2);
if (aa1.value==""){
document.getElementById(str2).style.backgroundColor = "#ffcccc";
}else{
document.getElementById(str2).style.backgroundColor = "#ffffff";
}
}
<input type="text" value="test1" onClick="Clear1(this.id);" id="textbox1" onblur="Clear2(this.id);">
<input type="text" value="test2" onClick="Clear1(this.id);" id="textbox2" onblur="Clear2(this.id);">
<input type="text" value="test3" onClick="Clear1(this.id);" id="textbox3" onblur="Clear2(this.id);">
<input type="text" value="test4" onClick="Clear1(this.id);" id="textbox4" onblur="Clear2(this.id);">
https://jsfiddle.net/warunamanjula/qy0hvmyq/1/
https://jsfiddle.net/warunamanjula/qy0hvmyq/1/
这篇关于清除文本框值并单击显示onblur的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文