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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:03:45+00:00 2026-06-09T13:03:45+00:00

In ASP.NET a RequiredFieldValidator still validates a textbox control even if I disabled it

  • 0

In ASP.NET a RequiredFieldValidator still validates a textbox control even if I disabled it on the client-side. I wanted to get rid of this behavior by using a CustomValidator. In the validation function I check if the text box is enabled. If that is the case I set the validator to valid.

function ValidateTextBox(sender, args) {

    var $textbox = $('#txtFoo')
    args.isValid = $textbox.prop('disabled') || $textbox.val();

}

This works fine on the client-side. The problem is, that I changed the state of the text box on the client-side using JavaScript. The server therefore does not know about the changed state (that the textbox control is disabled now). So when the ServerValidate event of the custom validator is raised (by calling Page.Validate for example) I cannot check whether the text box is disabled or not. Because the server does not know about this the Enabled property is always set to true, no matter what I do on the client-side.
How can I disable validation for controls when they are disabled or tell the server the state of the text box during Postback?

Thanks for your time.

  • 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-06-09T13:03:47+00:00Added an answer on June 9, 2026 at 1:03 pm
    1. Instead of making 'disabled' try to set textbox to 'ReadOnly' mode.

    2. You can Enable or Disable your RequiredFieldValidator at the time of you are disabling the textbox using ValidatorEnable JavaScript method
      (reference)

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

Sidebar

Related Questions

I've got an ASP.NET webform with asp:TextBox and asp:RequiredFieldValidator at the bottom of the
I have the following asp.net markup: <asp:TextBox ID=txtPassword runat=server TextMode=Password ValidationGroup=passwordValidation></asp:TextBox> <asp:RequiredFieldValidator ID=RequiredFieldValidator1 runat=server
My custom ASP.Net RequiredFieldValidator renders markup like this... var af1_ctl00 = document.all ? document.all[af1_ctl00]
I am writing in asp.net c#. I want a control similiar to RequiredFieldValidator except
Is there a way to run some custom Javascript whenever a client-side ASP.NET validator
Can you have custom client-side javascript Validation for standard ASP.NET Web Form Validators? For
ASP.Net 3.5 I want to create a user control that contains the ListView and
ASP.Net MVC Controllers have several methods of forwarding control to another controller or action.
ASP.NET MVC 2 will support validation based on DataAnnotation attributes like this: public class
I'm using ASP.NET WebForms and using some validation like the following: <asp:TextBox runat=server ID=txtUserName

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.