Side effect of calling ValidatorEnable method: sets focus to control associated with validator
Posted
by Velika2
on Stack Overflow
See other posts from Stack Overflow
or by Velika2
Published on 2010-05-01T04:46:16Z
Indexed on
2010/05/01
4:57 UTC
Read the original article
Hit count: 944
When I called this function to enable a validator from client javascript:
`ValidatorEnable(document.getElementById('<%=valPassportOtherText.ClientID%>'), true); //enable` validation control
The side effect was that focus was shifted to the txtSpecifyOccupation textbox (the control associated with the Validation control)
<asp:TextBox ID="txtSpecifyOccupation" runat="server" AutoCompleteType="Disabled"
CssClass="DefaultTextBox DefaultWidth" MaxLength="24" Rows="2"></asp:TextBox>
<asp:RequiredFieldValidator ID="valSpecifyOccupation" runat="server" ControlToValidate="txtSpecifyOccupation"
ErrorMessage="1.14b Please specify your <b>Occupation</b>"
SetFocusOnError="True"> Required</asp:RequiredFieldValidator>
Perhaps there is a way to enable the (required) validator without having it simultaneously perform the validation (at least until the user has tabbed off of it?)
© Stack Overflow or respective owner