Hi,
I have a page that has the following div:
<div id="divClient2" style="display:none" runat="server" >
<asp:Label ID="lblClient2" SkinID="form" runat="server"> </asp:
Label>
<asp:DropDownList ID="ddlTitle2" SkinID="ddlS" runat="server">
</asp:DropDownList>
<asp:RequiredFieldValidato
r ID="valTitle2" runat="server" ControlToValidate="ddlTitl
e2" Text="*" InitialValue="Title"></asp
:RequiredF
ieldValida
tor>
<asp:TextBox ID="txtForename2" SkinID="txtL" runat="server"></asp:TextB
ox>
<asp:RequiredFieldValidato
r ID="valForename2" runat="server" ControlToValidate="txtFore
name2" InitialValue="firstname" Text="*"></asp:RequiredFie
ldValidato
r>
<asp:TextBox ID="txtSurname2" SkinID="txtL" runat="server"></asp:TextB
ox>
<asp:RequiredFieldValidato
r ID="valSurname2" runat="server" ControlToValidate="txtSurn
ame2" InitialValue="surname" Text="*"></asp:RequiredFie
ldValidato
r>
</div>
As you can see the initial value is dispaly:none and some javascript toggles the div to be displayed or not:
function ShowHide()
{
var SelectedValue = document.getElementById('<
%=ddlClien
tNumber.Cl
ientID%>')
.value;
if(SelectedValue == "2")
{
document.getElementById('<
%=divClien
t2.ClientI
D%>').styl
e.display = 'block';
}
else
{
document.getElementById('<
%=divClien
t2.ClientI
D%>').styl
e.display = 'none';
}
}
Now, if the div is not displayed, validation is still required on the 3 "hidden" fields, what is the best workaround for this - I would like to validate the field if displayed and not if hidden???
Thanks in advance
Start Free Trial