Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can anyone know that it possible to display more than one error message for custom validator.if so how to display? I want to display error message for 2 reason, 1.if txtbox is empty and 2.if words mismatch with the one in database.
help me pls..
Posted

so are you not able to validate on Server side? Because you are validating from DB so you have to validate from server side.


<asp:CustomValidator runat="server" id="cusCustom" controltovalidate="txtCustom" onservervalidate="cusCustom_ServerValidate" errormessage="Error message!" />

protected void cusCustom_ServerValidate(object sender, ServerValidateEventArgs e)
{
    if(//validatation is true)
        e.IsValid = true;
    else
        e.IsValid = false;
}
 
Share this answer
 
Comments
Rakesh From Patna 26-Jul-11 6:15am    
also set validateEmptyText property
Generally, you would write only one message per textbox.

Thus if the text box is empty, you will write something like "this field is required" and you won't bother checking if the word matches a word in the database or not...

If the textbox is not empty, then you will do the next validation.
 
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