Use JavaScript in HTML to unblock input box code:

Source: Internet
Author: User

Turn: Differences between ReadOnly and disabled in a form

Resources:

Disabled and readonly differences:

Refer to post 1 address: http://blog.csdn.net/symgdwyh/article/details/5342937

 

1, <input type= "text" name= "name" value= " xxx "disabled=" true "/>

 

Both of these will make the displayed text box unable to enter text,

 

but disabled makes the text box gray and Request.getparameter ( "Name") does not get the contents of the text box (if any),

&NBSP;

Span style= "color: #0000ff; font-size:14pt; " And ReadOnly just makes the text box not input, the appearance does not change, and through Request.getparameter ("name") can get the content.

refer to post 2 address:http://www.nowamagic.net/html/html_ReadonlyAndDisabled.php

ReadOnly and disabled are the two attributes that are used in the form, and they all enable users to not change the content in the form fields. But there is a slight difference between them, summed up as follows:

ReadOnly is valid only for input (Text/password) and textarea, and disabled is valid for all form elements, including Select, Radio, CheckBox, Button, and so on.

However, when the form element is used with disabled, when we submit the form as a post or get, the value of this element is not passed out. and ReadOnly will pass the value out (this happens when we set the TEXTAREA element in a form to Disabled or readonly, but the Submit button is available).

My notes:

<!--         <from name= "..." action= "" method= "post" ></from> from       property:       Name form names that can be controlled       with other scripts after naming The Action Action property, the URL address of the submission. Method       property, the method for submitting data to a form has a GET or post two way. The              Input Property Type property is       entered in a format such as a text box, radio button, and a multi-box       Name property variable name that holds the submitted content.               type types are: Text textbox                   , submit submit, reset reset, password password,                   checkbox multi box, radio radio button, image Image, hidden hidden box, file.                                  <input type= "Submit" name= "Submission" value= "submit" > Submit        : Submission type, cannot omit        name: Default value "Name", can omit not to write        . Value: The text to be displayed on the Submit button, which shows the submission by default, can be omitted without writing.               <input type= "reset" name= "submit2" value= "reset" > Reset        : Commit type, cannot be omitted.        Name: You can make default values, which can be omitted without writing.        Value: The text to be displayed on the Submit button, which shows the submission by default,        can be omitted without writing.  -

JavaScript de-Disable input input box code:

function Disable () {      document.getElementById ("User.Name"). disabled= "";      document.getElementById ("User.number"). disabled= "";      document.getElementById ("User.age"). disabled= "";      document.getElementById ("User.sex"). disabled= "";      document.getElementById ("User.score"). disabled= "";     } </ Script >

Note: The variables within JavaScript correspond to the IDs in input.

The code you wrote is as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en"><Html><HEAD><Title>welcome page</Title><METANAME= "Generator"CONTENT= "EditPlus"><METANAME= "Author"CONTENT=""><METANAME= "Keywords"CONTENT=""><METANAME= "Description"CONTENT=""><!--Disable modify input box JavaScript effects start-<ScriptType= "Text/javascript">functionDisable () {document.getElementById ("User.Name"). Disabled=""; document.getElementById ("User.number"). Disabled=""; document.getElementById ("User.age"). Disabled=""; document.getElementById ("User.sex"). Disabled=""; document.getElementById ("User.score"). Disabled=""; }</Script><!--Disable modify input box JavaScript effect end-</HEAD><BODY><Br/><Br/><Br/><Br/><Br/><FormAction= "Http://www.baidu.com"><TableAlign= "Center"><Caption><nobr><H2> Your registration information is as follows:</H2></nobr></Caption><Tr><Td> Name:</Td><Td><InputId= "User.Name"Type= "Text"Name= "User.Name"Value= Nebula}Disabled= "true"></Td></Tr><Tr><Td> Number:<Br/></Td><Td><InputId= "User.number"Type= "Text"Name= "User.number"Value=1001Disabled= "true"></td> </tr> <tr> <td> Age:</td> <td><input id= "User.age" type= "text" name= "User.age" value= Disabled= "true" ></td> </tr> <tr> <td> gender:</td> <td> <select id= "User.sex" Style= "width:150px" name= "User.sex" disabled= "true" > <option value=${user.sex}> male <option value= "male" > Male <option value= "Women" > Women </select> </td> </tr> <tr> <td> score:</td> <td>< Input id= "User.score" name= "User.score" type= "text" value=88 disabled= "true" ></td> </tr> <tr> <td><input type= "Submit" value= "Confirm" onclick= "Disable ()" ></td> <td><input type= "button" Value= "Modify" onclick= "Disable ()"/></td> </tr> </table> </form> </BODY></HTML> 

Click Modify to remove the ban!

Use JavaScript in HTML to unblock input box code:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.