I use RegularExpressionValidators for the input text-boxes in my ASP.NET forms.
The GUI appears like. All the items are server controls and upon leaving the text box, I would display error message if the input is invalid.
I have enabled client-side validation with EnableClientScript in the RegularExpressionValidator. Once I leave the text box, it immediately fires the validator. But upon clicking on any button (causes to generate postback) removes the regular expression validators error display from the screen. How can I retrigger the client validation?
I am a newbie with asp.net
---------------------------
| | * Invalid input
---------------------------
Listbox A Listbox B
------------ ------------
| | | |
| | | |
| | >> | |
| | | |
| | | |
------------ ------------
Code goes like this.
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:TextBox ID="nameBox" runat="server" CssClass="StandardTextBox" Width="297px"
EnableViewState="true"></asp:TextBox>
<asp:RegularExpressionValidator ID="regExpValidatorRuleName2" align="left" runat="server"
ControlToValidate="nameBox"
Width="10px" Height="10px"
CssClass="StandardErrorLabel"
Display="Dynamic"
ErrorMessage="Input has Invalid character(s). Valid characters are a-z, A-Z, 0-9, _, @, ., -"
ValidationGroup="EditingPanel"
ValidationExpression="^[[email protected]]*$"
ToolTip="Input has Invalid character(s). Valid characters are a-z, A-Z, 0-9, _, @, ., -">*</asp:RegularExpressionValidator>
<asp:Panel ID="criteriaPanel1" GroupingText="Test" runat="server"
left="19px" CssClass="InputPanelTableLeft" Width="400px" Height="470px" Font-Bold="True"
Font-Size="X-Small">
<table class="InputPanelTable">
<tr>
<td align="left">
<asp:ListBox ID="listboxA" Rows="10" runat="server" EnableViewState="true"
Width="150px" Height="100px"></asp:ListBox>
</td>
<td style="padding: 0px 5px 0px 5px" valign="middle">
<asp:Button ID="buttonMove" runat="server" OnClick="buttonMove_OnClick"
Text=">>" ToolTip="Moves selected item from left side to right" />
</td>
<td align="left">
<asp:ListBox ID="listboxB" Rows="10" runat="server" EnableViewState="true"
Width="150px" Height="100px"></asp:ListBox>
</td>
</tr>
</table>
</asp:Panel>
</asp:Content>