在asp.net中使用javascript更改文本框颜色 [英] change the text box color with javascript in asp.net
本文介绍了在asp.net中使用javascript更改文本框颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以帮助我吗?验证为假时,如何使用javascript更改文本框颜色?例如,如果我检查null验证,则在文本框中未输入任何内容,它应在文本框中显示红色,表示您应在文本框中输入某些内容.
解决方案
//C# TextBox1.BackColor = System.Drawing.Color.Red; //Javascript<br /> document.getElementById("TextBox1").style.backgroundColor = "#FF0000";
如果有帮助,请 投票 和 接受答案 .
Can any one help me? How do I change the text box color with javascript when validation is false? For example, if I check for null validation then I enter nothing in the textbox, it should show the colour red in the textbox, indicating that you should enter something in the textbox.
解决方案
//C# TextBox1.BackColor = System.Drawing.Color.Red; //Javascript<br /> document.getElementById("TextBox1").style.backgroundColor = "#FF0000";
Please vote and Accept Answer if it Helped.
function btn_validate_click(events){ if(document.getelementbyid("textbox1").text + "" = ""){ lblValidation.Text = "Nothing has been entered."; document.getelementbyid("textbox1").ForeColor = "Red"; document.getelementbyid("textbox1").BackColor = "Yellow"; // or whatever colours u want. } }
这篇关于在asp.net中使用javascript更改文本框颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文