I want to make a validation on the name, to force the user to input his name in four sections (four names). How to do that on the client side, using asp.net validation?
<td style="text-align: right;" class="style1">
<asp:TextBox ID="txt_addName" runat="server" Width="220px" ValidationGroup="add"></asp:TextBox>
<cc1:TextBoxWatermarkExtender ID="txt_addName_TextBoxWatermarkExtender"
runat="server" Enabled="True" TargetControlID="txt_addName"
WatermarkText="أدخل اسم المحاضر رباعيا" WatermarkCssClass="watermark">
</cc1:TextBoxWatermarkExtender>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server"
ControlToValidate="txt_addName" Display="Dynamic" ErrorMessage="!"
ValidationGroup="add"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="*"
ValidationExpression="^(?:\p{L}+\s+){3}\p{L}+$" ControlToValidate="txt_addName"
Display="Dynamic" ValidationGroup="add">يجب أن يكون اسم المحاضر رباعيا
</asp:RegularExpressionValidator>
</td>
<td style="text-align: center; width: 550px;">
<asp:Button ID="btn_addNewLecterer" runat="server" Font-Bold="True" Font-Names="Garamond"
Font-Size="Medium" Text="أضف محاضر جديد" OnClick="btn_addNewLecterer_Click" ValidationGroup="add" />
</td>
Something like this should work:
Explanation:
If you want to limit the expression to require exactly four sections (I interpreted the question as requiring at least four), you change it to: