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

  • Home
  • SEARCH
  • 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 775973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:22:35+00:00 2026-05-14T19:22:35+00:00

I have a frame with several radio buttons where the user is supposed to

  • 0

I have a frame with several radio buttons where the user is supposed to select the “Category” that his Occupation falls into and then unconditionally also specify his occupation.
alt text

If the user selects “Retired”, the requirement is to prefill “Retired” in the “Specify Occupation” text box and to disable it to prevent it from being changed. The Specify Occupation text box should also no longer be a tab stop. If the user selects a radio button other than Retired the Specify Occupation text box should be enabled and once again and the Specify Occupation text box should once again be in the normal tab sequence.

Originally, I was setting and clearing the disabled property on the Specify occupation textbox, then I found out that, upon submitting the form, disabled fields are excluded from the submit and the REQUIRED validator on the Specify Occupation textbox was being raised because the textbox was being blanked out.

What is the best way to solve this? My approach below was to mimic a disabled text box by setting/resetting the readonly attribute on the text box and changing the background color to make it appear disabled. (I suppose I should be changing the forecolor instead of teh background color). Nevertheless, my code to make the textbox readonly and to reset it doesn’t appear to be working.

    function OccupationOnClick(sender) {

        debugger;
        var optOccupationRetired = document.getElementById("<%= optOccupationRetired.ClientId %>");
        var txtSpecifyOccupation = document.getElementById("<%= txtSpecifyOccupation.ClientId %>");
        var optOccupationOther = document.getElementById("<%= optOccupationOther.ClientId %>");

    if (sender == optOccupationRetired) {

        txtSpecifyOccupation.value = "Retired"
        txtSpecifyOccupation.readonly = "readonly";
        txtSpecifyOccupation.style.backgroundColor = "#E0E0E0";
        txtSpecifyOccupation.tabIndex = -1;
    }
    else {
        if (txtSpecifyOccupation.value == "Retired")
            txtSpecifyOccupation.value = "";
        txtSpecifyOccupation.style.backgroundColor = "#FFFFFF";
        txtSpecifyOccupation.readonly = "";
        txtSpecifyOccupation.tabIndex = 0;
    }
}

Can someone provide a suggestion to me on the best way to handle this scenario and provide a tweek to the code above to fix the setting/resetting on the readonly property?

  • 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-14T19:22:36+00:00Added an answer on May 14, 2026 at 7:22 pm

    I recently had to do the same thing. Here’s how I solved it.

    1. go back to using the disabled property rather than readonly.

    2. replace the RequiredFieldValidator with a CustomValidator. in your client and server validation functions, determine if you need to check the text input based on the condition of the Retired radio button. then check for input in the text box if you need to. (on the js side you can check the disabled property on the textbox itself to save yourself a step).

    3. on the server side you should double check the radio button selection, and if “Retired” is selected, you should make sure that “Occupation” value is actually “Retired”. this gets you around the issue of not getting a value from a disabled field, and you should be doing it anyway (never trust the user and all that).

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

Sidebar

Related Questions

I have several lists that I'm trying to enter into a data frame: mydates
I have a data frame with several factor columns containing NaN 's that I
I have several buttons in various sizers and they expand in the way that
I am trying to merge several data.frames into one data.frame . Since I have
I have a data.frame that contains historic data by day for several months. I
I have a data frame with several columns. I want to select the rows
I have data.frame that contains several factors and i want to rename factor levels
I have a data frame with several variables. What I want is create a
I have a wx.Frame, in which there is a main wx.Panel with several widgets
I have a custom UITableViewCell which contains several UIButtons. Each button's frame position is

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.