Comparison of form element attributes readonly and disabled


1) Scope of application:
Disabled: all form elements, such as select, radio, check box, button, etc

2) Operation:
Readonly: the user is not allowed to modify the operation and does not affect any other operation
Disabled: prevent users from doing everything, including clicking events and getting focus events

3) Form submission:
Readonly: the values of form elements can be submitted to the server.
Disabled: the value of the form element is not submitted to the server, that is, the server cannot get the value in this form element

Common applications:

a> A unique identification code is pre filled for the user in a form, which is not allowed to be changed by the user. However, the value needs to be passed when submitting, and its properties should be set at this time


b> To prevent the form from submitting repeatedly, use JavaScript to disable the submit button (form button) after submitting the form.

c> Set read only in checkbox and radio: disable default events
For example: bind (“click”, function() {return false;}) in jQuery;

Recommended Today

Tutorial on sending e-mail using net:: SMTP class in Ruby

Simple Mail Transfer Protocol(SMTP)SendE-mailAnd routing protocol processing between e-mail servers. RubyIt provides the connection of simple mail transfer protocol (SMTP) client of net:: SMTP class, and provides two new methods: new and start New takes two parameters: Server name defaults to localhost Port number defaults to 25 The start method takes these parameters: Server – […]