Control textbox-interesting attributes

Source: Internet
Author: User

 
1. Differences between readonly = 'true' and enabled = 'false' in textbox attributes

 

The HTML server control uses a class derived from the htmlcontrol base class (full Class Name: system. Web. UI. htmlcontrols). Only the disabled property is available in this class.

 

Per W3C specification: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.12

 

 

The textbox of the readonly attribute will display such a mark on the client:

 

 

<Input readonly = "readonly">

 

The following restrictions apply to input with readonly:

 

<1> acceptable focus, but not modifiable <2> navigation using the tab key <3> Successful

 

 

The textbox of the enabled attribute will present such a flag on the client:

 

 

<Input Disabled = "disabled">

 

If the input parameter is set to disabled, the following restrictions apply:

 

<1> acceptable focus <2> skipped when the tab key is used <3> it may not be successful

 

 

 Only the form element of successful is valid data, that is, the text input boxes that can be submitted. Disabled and readonly can only be modified using scripts.

 

 

 

 

 

2. textmodel = 'Password' in textbox'

 

If you want to assign a value to the password box, textbox. Text = "XXX"; will not work.

 

Use the background registration: txtpassword. Attributes. Add ("value", "xxxxxx ");

 

 

3. Retain user input

 

The textbox server control does not exist. However, when you use the <input type = "text"/> client control, the value is cleared if the client is redirected to the control.

 

Required: <input type = "text" style = "behavior: URL (# default # savehistory);"/>

 

 

4. It can only be numbers (with flashing) 

 

<Asp: textbox id = "textbox1" runat = "server"Onkeyup = "value = value. replace (/[^ \ D]/g, '')" onbeforepaste = "clipboardData. setdata ('text', clipboardData. getdata ('text '). replace (/[^ \ D]/g ,''))"> </ASP: textbox>

 

Test:

 

 

 

5. Only English and numbers can be entered (with flashing)

 

<Asp: textbox id = "textbox1" runat = "server"Onkeyup = "value = value. replace (/[\ W]/g, '')" onbeforepaste = "clipboardData. setdata ('text', clipboardData. getdata ('text '). replace (/[^ \ D]/g ,''))"> </ASP: textbox>
Test:

 

 

 

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.