问题描述
嗨
我有一个名称为 txt1 的文本框.
在javascript中,我将 txt1 设为必填项,但现在我添加了一个下拉列表.
因此,现在 txt1 仅在选择下拉列表的特定值时才是必需的.
这意味着,当我从下拉列表中选择 name 时,则必须 txt1 ,而当我从下拉列表中选择 class 时, txt1 >应该设置为可见关闭.
现在,当我在下拉列表中选择 class 时,使 txt1 可见为false,但这会抛出 javascript错误,表明 txt1 在下一行中为null.
但是当我从下拉列表中选择 name 时,就不会出现错误,因为它是可见的.
Hi
I have a textbox with name txt1.
In javascript, I am making txt1 mandatory, but now I have a added dropdownlist.
So, now txt1 is mandatory only when, the specific value of dropdown is selected.
That means, when I select name from dropdown, then txt1 is mandatory and when I select class from dropdown the txt1 should set to visible off.
Now I make txt1 visible to false, when i select class in dropdown, but it is throwing javascript error that txt1 is null in following line.
But when I select name from dropdown then no error comes because it is visible.
if(document.getElementById('<%=Txt1.ClientID%>').value=="")
推荐答案
这篇关于javascript textbox1为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!