There are two ways to display information in common form fields but not allow a user to change the data—by setting the field to read-only or disabled.
You can add the readonly attribute to text fields to keep the user from being able to edit the data contained therein.
The disabled attribute effectively disables a control (usually graying out the control, consistent with the user agent’s platform method of showing disabled controls) so the user cannot use the control.
The following code shows examples of both a read-only and a disabled control. The output of this code.
Disabled and read-only fields can be used to show data without the data being edited.
Although the two attributes make the fields look similar on screen, the readonly field can be selected, just not edited. The disabled field cannot be selected at all.
Tip: Disabling a control that is not applicable in certain instances is common practice. For example, international addresses do not have a U.S. ZIP code. If a user indicates that they have an international address, you might decide to disable the ZIP code field so they do not enter data in that field.
You can use client-side scripts to dynamically disable controls. Use onblur or onchange attributes to call a script from fields that could change the enabled status of other fields—those scripts check the data entered and enable or disable other fields by changing the value of that field’s disabled attribute.
HTML Related Interview Questions
|XML Interview Questions||HTML 4 Interview Questions|
|HTML Interview Questions||HTML 5 Interview Questions|
|HTML DOM Interview Questions||Java Interview Questions|
|CSS Interview Questions||Java Abstraction Interview Questions|
|Dynamic HTML Interview Questions||XHTML Interview Questions|
Introducing The Web And Html
What Goes Into A Web Page?
Starting Your Web Page
Lines, Line Breaks, And Paragraphs
Page Layout With Tables
Introducing Cascading Style Sheets
Creating Style Rules
Padding, Margins, And Borders
Colors And Backgrounds
Tables Table Styles
Defining Pages For Printing
Dynamic Html With Css
Introduction To Server-side Scripting
Introduction To Database-driven Web Publishing
Creating A Weblog
Introduction To Xml
Xml Processing And Implementations
Testing And Validating Your Documents
Choosing A Service Provider
Uploading Your Site With Ftp
Publicizing Your Site And Building Your Audience
Maintaining Your Site
The Web Development Process
Developing And Structuring Content
Designing For Usability And Accessibility
Designing For An International Audience
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.