i have register form in asp, it has 30 input box that all of them have RequiredFieldValidator
. when user click on submit how can i found out that at least one of input is not filled and show error next to the submit button and input control?
<fieldset>
<legend>title :</legend>
<asp:Table ID="Table3" runat="server">
<asp:TableRow runat="server">
<asp:TableCell runat="server"> :</asp:TableCell>
<asp:TableCell runat="server">
<asp:TextBox ID="txtMadrakTahsili" runat="server" CssClass="Width"></asp:TextBox><asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server"
ErrorMessage="*" Display="Dynamic" ControlToValidate="txtMadrakTahsili"></asp:RequiredFieldValidator>
</asp:TableCell>
<asp:TableCell runat="server">reshte :</asp:TableCell>
<asp:TableCell runat="server">
<asp:TextBox ID="txtReshteTahsili" runat="server" CssClass="Width"></asp:TextBox><asp:RequiredFieldValidator ID="RequiredFieldValidator25" runat="server"
ErrorMessage="*" Display="Dynamic" ControlToValidate="txtReshteTahsili"></asp:RequiredFieldValidator></asp:TableCell>
<asp:TableCell ID="TableCell7" runat="server">mahale akhz :</asp:TableCell>
<asp:TableCell ID="TableCell8" runat="server">
<asp:TextBox ID="txtMahalAkhzMadrak" runat="server" CssClass="Width"></asp:TextBox><asp:RequiredFieldValidator ID="RequiredFieldValidator14" runat="server"
ErrorMessage="*" Display="Dynamic" ControlToValidate="txtMahalAkhzMadrak"></asp:RequiredFieldValidator></asp:TableCell>
</asp:TableRow>
<asp:TableRow runat="server">
<asp:TableCell runat="server">avg</asp:TableCell>
<asp:TableCell runat="server">
<asp:TextBox ID="txtMoadel" runat="server" CssClass="Width"></asp:TextBox><asp:RequiredFieldValidator ID="RequiredFieldValidator15" runat="server"
ErrorMessage="*" Display="Dynamic" ControlToValidate="txtMoadel"></asp:RequiredFieldValidator></asp:TableCell>
</asp:TableRow>
</asp:Table>
</fieldset>
if one og inpuut is not filled , show error next to this button to !
<p style="float:left; clear:both;">
<asp:Button ID="Button1" runat="server" Text="ثبت اطلاعات" Height="54px"
style="margin-right: 0" Width="119px" onclick="Button1_Click" /></p>
When you use
Text="*"it will be shown next toTextboxif you placed it near theTextbox.The
ErrorMessageproperty is useful when you want to show all validation errors together.So if you want to show
Error Messagesassociated with theTextboxesthen I suggest you useASP.NETValidationSummarycontrolValidation Summary Control
EXAMPLE: