Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6201899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:38:15+00:00 2026-05-24T04:38:15+00:00

I need to validate various ASP.NET controls, but instead of displaying the standard text/asterisk/image

  • 0

I need to validate various ASP.NET controls, but instead of displaying the standard text/asterisk/image next to each when validation fails, I need to display custom content (change the outline color of the input textbox, display a tooltip, etc.). I could use a standard validation control in most cases (e.g., RequiredFieldValidator for a TextBox), except for the display when validation fails.

I’ve started out creating CustomValidators, but I need to do this many times for various validations (required field, regular expressions, ranges). It seems a waste to recreate the logic of these validators only so that it can change the response output. The MS documentation at http://msdn.microsoft.com/en-us/library/3w0bs977.aspx says a custom response can be done on both client and server in this case: “On both the client and server side you can create a custom response, such as a color change in a control or a font change for text on a label.” It gives an example for the server side, but does not give a method for the client side. What is the best way to handle the custom response on the client?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:38:16+00:00Added an answer on May 24, 2026 at 4:38 am

    This article might help you:

    http://msdn.microsoft.com/en-us/library/aa479045.aspx

    Particularly this section (look for “Client Side Validation” then under there, “Special Effects”):

    <asp:Label id=lblZip runat=server 
       Text="Zip Code:"/> 
    <asp:TextBox id=txtZip runat=server 
       OnChange="txtZipOnChange();" /></asp:TextBox><br>
    <asp:RegularExpressionValidator id=valZip runat=server
       ControlToValidate=txtZip
       ErrorMessage="Invalid Zip Code" 
       ValidationExpression="[0-9]{5}" /><br>
    
    <script language=javascript>
    function txtZipOnChange() {
       // Do nothing if client validation is not active
       if (typeof(Page_Validators) == "undefined")  return;
       // Change the color of the label
       lblZip.style.color = valZip.isvalid ? "Black" : "Red";
    }
    </script>
    

    There is still some wiring up that needs to be done, which you may be able to tidy up with some jQuery or the like

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently using the validate plugin to validate a form (using ASP.Net controls).
I need to validate a byte[] in my model as Required but whenever I
I need to validate the text box value from the generated html table (grid)
I need to validate two user input fields against each other in seam. Field1
I have a Races table with many races in various states. But I need
I need validate the dynamically appended input text box for the below code $(#btnadd).click(function()
I need to validate a date/time field on a webpage but want it to
I need to clean-up and validate some html markup in various places. I'm currently
I need to validate X number of fields. Each field is named testFieldX, where
I need to validate a form with a bunch of inputs in it. And,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.