Click here to Skip to main content
15,914,416 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
Does a Conditional Client side validation exist like for ex.

done part
I have a bind dropdownlist which contains years, during the page load it queries the year and select the year which the user have saved lets say "2011".


My problem is I want to validate that the user didn't choose a blank item.

like

""
"2010"
"2011"
"2012"
"2013"

EDIT:

forgot the Conditional part
The Datasource comes from a List and at the last entry of the List I've added "Others" which means that the year didn't exist on the database, user can add the year that he wan't. If the user select Others a textbox for the other year will be visible and then I want to check if know if there is a condition if user only select existing year o Other.

PS: sorry for my bad English
Posted
Updated 30-Sep-13 22:26pm
v2
Comments
Thanks7872 1-Oct-13 3:50am    
Not at all clear. What do you mean by Conditional custom Validation?
iMaker.ph 1-Oct-13 4:36am    
I've updated my question, sorry for that.
pradiprenushe 1-Oct-13 4:30am    
Use required field validator with InitialValue property

 
Share this answer
 
XML
The RequiredFieldValidator is actually very simple, and yet very useful. You can use it to make sure that the user has entered something in a TextBox control. Let's give it a try, and add a RequiredFieldValidator to our page. We will also add a TextBox to validate, as well as a button to submit the form with. <form id="form1" runat="server">
    Your name:<br />
    <asp:TextBox runat="server" id="txtName" />
    <asp:RequiredFieldValidator runat="server" id="reqName" controltovalidate="txtName" errormessage="Please enter your name!" />
    <br /><br />
    <asp:Button runat="server" id="btnSubmitForm" text="Ok" />
</form>
 Actually, that's all we need to test the most basic part of the RequiredFieldValidator. I'm sure that all the attributes of the controls makes sense by now, so I won't go into details about them. Try running the website and click the button. You should see something like this:
 
Share this answer
 

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