Disabled and readonly of input and their limitations

Source: Internet
Author: User

<Input name = "country" id = "country" size = 12 value = "this value is not obtained when disabled is submitted." Disabled = "disabled"> 
This value is not obtained after being submitted in the form. 
Change Disabled = "disabled" to readonly = "readonly ". 
Per W3C specification: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.12 
If the input parameter is set to disabled, the following restrictions apply: 
Cannot receive focus 
The tab key is skipped. 
It may not be successful's

The following restrictions apply to input with readonly: 
Can receive the focus but cannot be modified 
You can use the tab key for navigation. 
It may be successful's 
Only the form element of successful is valid data, that is, it can be submitted. The disabled and readonly text input boxes can only be modified using scripts.

Bytes ---------------------------------------------------------------------------------------------------

 

1. When the cancel button is pressed, add the value hidefocus or hidefocus = true to the input.  
<Input type = "Submit" value = "Submit" hidefocus = "true"/>

2. Read-only text box content, add the attribute value readonly in input  
<Input type = "text" readonly/>  

3. Prevent text files from being cleared (style content can be referenced as a class)  
<Input type = "text" style = "behavior: URL (# default # savehistory);"/>
 
4. Press enter to move the cursor to the next input box.  
<Input type = "text" onkeydown = "If (event. keycode = 13) event. keycode = 9"/>

5. It can only be Chinese (with flashing)  
<Input type = "text" onkeyup = "value = value. Replace (/[-~] /G, '')" onkeydown = "If (event. keycode = 13) event. keycode = 9"/>

6. Only numbers are allowed (with flashing)  
<Input type = "text" onkeyup = "value = value. replace (/[^ \ D]/g, '')" onbeforepaste = "clipboardData. setdata ('text', clipboardData. getdata ('text '). replace (/[^ \ D]/g, '')"/>

7. Only numbers are allowed (no flashing) 
<Input type = "text" style = "ime-mode: Disabled" onkeydown = "If (event. keycode = 13) event. keycode = 9 "onkeypress =" If (event. keycode <48 | event. keycode> 57) event. returnvalue = false "/>

8. Only English and numbers can be entered (with flashing)  
<Input type = "text" onkeyup = "value = value. replace (/[\ W]/g, '')" onbeforepaste = "clipboardData. setdata ('text', clipboardData. getdata ('text '). replace (/[^ \ D]/g, '')"/>

9. shielded Input Method  
<Input type = "text" name = "url" style = "ime-mode: Disabled" onkeydown = "If (event. keycode = 13) event. keycode = 9 "/>
 
10. You can only enter numbers, decimal points, minus (-) characters (no flashing)  
<Input onkeypress = "If (event. keycode! = 46 & event. keycode! = 45 & (event. keycode <48 | event. keycode> 57) event. returnvalue = false "/>
 
11. Only two decimal places can be entered, and three decimal places (with flashing)  
<Input type = "text" maxlength = "9" onkeyup = "If (value. match (/^ \ D {3} $/) value = value. replace (value, parseint (value/10); value = value. replace (/\. \ D *\. /g ,'. ') "onkeypress =" If (event. keycode <48 | event. keycode> 57) & event. keycode! = 46 & event. keycode! = 45 | value. match (/^ \ D {3 }$/) | /\. \ D {3} $ /. test (value) {event. returnvalue = false} "/>

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.