Coding⏱️ 2 min read📅 2026-06-03

How to Fix: How to ensure a <select> form field is submitted when it is disabled?

Submit select form field when disabled using readonly attribute.

Quick Answer: Use the readonly attribute on a hidden input element to mimic the behavior of a readonly select field, while still allowing it to be submitted with the form.

📋 Table of Contents

  1. ✅ Solution:
  2. 🎯 Final Words

To ensure a <select> form field is submitted when it is disabled, you can use the readonly attribute in combination with JavaScript. When the user clicks on the select element and tries to change its value, you can prevent the default action using event handling.

✅ Solution:

Using JavaScript to Enable Form Submission

  1. Step 1: Add the readonly attribute to your select element:
  2. <select readonly>...
  3. Step 2: Wrap your select element in a container and add an event listener using JavaScript:
  4. document.querySelector(\'.select-container\').addEventListener(\'click\', function(event) {...
  5. Step 3: Prevent the default action when the user clicks on the select element and tries to change its value:
  6. event.preventDefault();
  7. Step 4:: Submit the form using JavaScript:
  8. document.querySelector(\'.select-container\').submit();

🎯 Final Words

By following these steps, you can enable form submission for a disabled select element using JavaScript.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions