How do you disable enable a textbox input when radio button is selected deselected?

  1. function EnableDisableTextBox() {
  2. var chkYes = document.getElementById(“chkYes”);
  3. var txtPassportNumber = document.getElementById(“txtPassportNumber”);
  4. txtPassportNumber.disabled = chkYes.checked ?
  5. if (!txtPassportNumber.disabled) {

How to enable and disable radio button In JavaScript?

You can enable and disable the radio button by using the disabled property of HTML DOM. Set this property to true (disable=true) to disable the radio button in JavaScript.

How do I disable radio buttons?

You can check a radio button by default by adding the checked HTML attribute to the element. You can disable a radio button by adding the disabled HTML attribute to both the and the .

How do I enable and disable a textbox in HTML?

How to enable/disable text field using JavaScript

  1. Register enable() and disable() function with buttons to enable and disable text field.
  2. Use the getElementById() to grab the text field.
  3. Set the disabled field to true or false.

How do I make a radio button read only?

Using the readonly attribute doesn’t work with radio buttons. This can be accomplished by simply adding an onclick=”return false;”. This also allows the radio buttons to look normal without being grayed out.

How to enable or disable textbox using JavaScript?

In this tutorial, you will learn how to enable/disable textbox using JavaScript on the radio button click. In the below example, it will create three radio buttons and three textboxes and will enable or disable on the radio button click using JavaScript.

How to disable textbox on radio button click?

I have two radio buttons. each radio button has two TextBox I just want to do if first radio button is clicked then other radio button containing textboxes should be disabled and vice versa.

How to disable radiobutton group in JavaScript Stack Overflow?

Or, if you’d prefer, you can extend the Object prototype to allow you to directly disable those elements returned by the document.getElementsByName () selector: Simple demo. Thanks for contributing an answer to Stack Overflow!

What does the disabled button on a radio button do?

The disabled property sets or returns whether a radio button should be disabled, or not. A disabled element is unusable and un-clickable. Disabled elements are usually rendered in gray by default in browsers.