Click here to Skip to main content
15,891,680 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have assigned a required field validator to a textbox. I should get an error message if that field is empty. This error message should come when I click the submit button and the values that I have entered in the other textboxes on the same page should not be stored in the database.
In short the empty values should not be stored into the database.
Can anyone help me out?
Posted
Updated 30-Aug-10 21:13pm
v2

Try this example and see how I used the RequiredFieldValidator to make sure that user enters the Name field. I believe, you can implement your own :)

XML
<div>
       <asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
       <asp:TextBox ID="TxtName" runat="server"></asp:TextBox><asp:RequiredFieldValidator
           ID="RequiredFieldValidator1" ControlToValidate="TxtName" runat="server" ErrorMessage="Name is required."></asp:RequiredFieldValidator>
       <br />
       <asp:Label ID="Label2" runat="server" Text="Address"></asp:Label>
       <asp:TextBox ID="TxtAddress" runat="server"></asp:TextBox>
       <asp:Button ID="Button1" runat="server" Text="Submit" />
   </div>
 
Share this answer
 
Comments
srujanac# 31-Aug-10 3:35am    
i got it but it is not working for fckeditor i ned to check it out whether validation controls work for fckeditor
Dalek Dave 31-Aug-10 3:36am    
Good Call
Al-Farooque Shubho 31-Aug-10 4:14am    
No, Validation control won't work for FCKEditor because, the FCKEditor actually renders an IFrame, in place of the text area.
You have to write Custom validation code for that.
A validator does that, it stops the page posting back.
 
Share this answer
 
Comments
srujanac# 31-Aug-10 3:15am    
ya i got it visible should be true which i have kept it false
srujanac# 31-Aug-10 3:36am    
i got it but it is not working for fckeditor i ned to check it out whether validation controls work for fckeditor

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900