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 6083955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:27:51+00:00 2026-05-23T11:27:51+00:00

In a web form there are different asp.net validation controls. Is it possible to

  • 0

In a web form there are different asp.net validation controls. Is it possible to check a particular validation control is valid ? For example on leaving focus of textbox, first I will check requiredFieldValidatorUserName is valid ? If it is valid then I will check on server using ajax that this user name is not booked already.

Edit:

Explaination: I want to check validity (that input was valid) of a validation control on client side.

Please guide.

  • 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-23T11:27:51+00:00Added an answer on May 23, 2026 at 11:27 am

    The best way would be to use a CustomValidator with client side code, as this will display all the error messages, block form submission and also ensure that the validation is repeated at the server side – remember, just because you have client-side validation available, doesn’t mean the user’s seen it: Always validate your input at the server as well.

    Your CustomValidator would then be coded to call the Ajax methods, and would show the error messages correctly to the client:

    <asp:Label ID="UserNameLabel" AssociatedControlID="UserName" runat="server">
      UserName *:</asp:Label>
    <asp:TextBox ID="UserName" runat="server" />
    <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" 
                                ControlToValidate="UserName" EnableClientScript="true"
                                ErrorMessage="You must supply a username!" />
    <asp:CustomValidator ID="UserNameCustom" runat="server"
                         ControlToValidate="UserName" 
                         ClientValidationFunction="CheckExisting"
                         OnServerValidate="UserNameCustomValidate"
                         ErrorMessage="Username already taken" />
    

    And your ClientValidationFunction should look something like:

    <script type="text/javascript">
      function CheckExisting(source, arguments) {
        // Pass the arguments.Value to your AJAX call:
        if (ajaxCallUserNameTaken(arguments.Value)) {
          arguments.IsValid = false;
        }
      }
    </script>
    

    (Obviously, you’ll need to write the ajaxCallUserNameTaken method to call your page method/web service/etc.)

    Doing it this way will ensure that the validation methods happen as expected; this will get called whenever the user tabs out of the textbox leaving a value (it won’t get called if the textbox is empty), and will ensure that the user can’t submit the page until they supply a unique value. You’ll also want to create the method referenced in OnServerValidate to ensure that the value’s good once it hits the server too – this should call the same code that the AJAX endpoint uses to reduce duplication of code, etc.

    I was originally going to suggest that you could use the Page_Validators object on the client-side to do some checking in the onBlur event, but I don’t really think this is suitable here as it results in more pain:

    1. It assumes that although there might be more than one validator on the page, there’s only the RequiredFieldValidator on the control we’re checking
    2. The RequiredFieldValidator isn’t fired during OnBlur if a user moves out of a control without setting a value – only if they set and clear the value, so even if isvalid is true, you need to check for an empty string!
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a bunch of different asp.net validation controls on a web form. Some
I'm writing an ASP.NET 3.5 web application. There is a rather complex input form
Assuming there are 5 inputs in web form <input name='the_same[]' value='different' /> <input name='the_same[]'
I am writing a SharePoint web part which will have a simple ASP.NET form.
We have got a custom MembershipProvider in ASP.NET . Now there are 2 possible
I'm making a web app. In it there are times when a form may
In a .Net web form... What are these special tags called? I know of
I have a web form that binds a DataGrid to a, normally, different data
I am working on some ASP.NET web forms which involves some dynamic generation, and
I've got an ASP.NET 3.5 Web Forms application in which a large chunk of

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.