DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Dynamic Web Forms In React For Enterprise Platforms
  • How to Get Word Document Form Values Using Java
  • Lightning Data Service for Lightning Web Components
  • Dynamic Forms With Camunda and Spring StateMachine

Trending

  • Build Your First AI Model in Python: A Beginner's Guide (1 of 3)
  • Scalable, Resilient Data Orchestration: The Power of Intelligent Systems
  • Stateless vs Stateful Stream Processing With Kafka Streams and Apache Flink
  • A Developer's Guide to Mastering Agentic AI: From Theory to Practice

HTML/JSP Disabled Form Field's Strange Behavior

This post will show you how to generate disabled field behavior for any of the input fields in HTML. Read on to learn more.

By 
Shidram BJ user avatar
Shidram BJ
·
Jan. 09, 16 · Tutorial
Likes (5)
Comment
Save
Tweet
Share
22.8K Views

Join the DZone community and get the full member experience.

Join For Free

Disabled Form Fields of HTML Will Not Get the Values (Null) After Submitting the Form

Using the code below for the input form fields in HTML will generate the disabled field. The disabled field is the one which is not editable, not focusable, won’t get tab navigation, and can’t select the field. We can apply this attribute on all input fields, buttons, select box, etc. 

Please see the code below:

<input type=”text” name=”accountNumber” value=”123455” disabled=”disabled”   />

This will generate the disabled text field where we are unable to edit and select the field.

Characteristics of Disabled Form Fields

  1. Disabled form field cannot be focusable, i.e., you cannot focus the field. 
  2. Disabled fields are non-editable.
  3. Disabled fields will not be submitted when submission of the form happens or when we click on the Submit button.
  4. Disabled fields will give null values after submitting the form where you are getting the values (it may be struts action class in case of struts or servlet class in case of servlets).
  5. We can modify the values of disabled fields only through JavaScript at the client side.

How to Get Disabled Behavior for Any of the Input Fields and Get the Non-null Values After Form Submission

  1. Make the field readOnly instead of disabled  by putting the attribute as readonly=”readonly” for html fields and readOnly=”true” for struts JSP fields.
  2. Prepare the CSS with the color of disabled fields (i.e. gray color), and apply the CSS to the fields which you made as readonly. Now the field is uneditable because of the readonly attribute and looks like the disabled field because of the CSS applied.

Characteristics of readonly Fields

  1. Fields are not editable through the screen.
  2. Fields can be modified through JavaScript code at client side.
  3. Fields can be Focusable.
  4. Fields can be selectable.
  5. Tab navigation is possible on the fields.
  6. Values can be submitted after form submission.
  7. There are no null values after form submission whenever the field contains values while submitting.

This will solve the issue with disabled fields used in the view layer for a specific purpose and will help to get the disabled behavior.

For other posts please visit my blog : Journey Towards Java


Form (document)

Published at DZone with permission of Shidram BJ. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Dynamic Web Forms In React For Enterprise Platforms
  • How to Get Word Document Form Values Using Java
  • Lightning Data Service for Lightning Web Components
  • Dynamic Forms With Camunda and Spring StateMachine

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: