Deepak Ratan

Deepak Ratan

  • NA
  • 175
  • 50.5k

How can we use two RequiredFieldValidator?

May 11 2015 5:25 AM
Textbox 1:
 
<asp:TextBox ID="txtpost" runat="server" TextMode="MultiLine" Height="55px" Width="1000px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Invalid Status" ControlToValidate="txtpost" ForeColor="Red"></asp:RequiredFieldValidator> 
 <asp:Button ID="btnpost" runat="server" Text="Post" CssClass="inputs" OnClick="btnpost_Click"/> 
 
Textbox 2:
 
<asp:TextBox ID="txtcommt" runat="server" CssClass="validate[required]"></asp:TextBox>
 <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Invalid Status" ControlToValidate="txtcommt" ForeColor="Red"></asp:RequiredFieldValidator>
<asp:Button ID="btncmd" runat="server" Text="Post" OnClick="txtcmd_Click"/>
 
 
How to validate the textbox without affecting to the another textbox
Using this method i am getting the Issue that if both textbox has the value only its executing,other wise its showing the ErrorMessage

Answers (6)