input型別和限制
1.取消按鈕按下時的虛線框,在input裡新增屬性值 hideFocus 或者 HideFocus=true
<input type="submit" value="提交" hidefocus="true" />
2.只讀文字框內容,在input裡新增屬性值 readonly
<input type="text" readonly />
3.防止退後清空的TEXT文件(可把style內容做做為類引用)
<input type="text" style="behavior.:url(#default#savehistory);" />
4.ENTER鍵可以讓游標移到下一個輸入框
<input type="text" nkeydown="if(event.keyCode==13)event.keyCode=9" />
5.只能為中文(有閃動)
<input type="text" nkeyup="value=value.replace(/[ -~]/g,'')" nkeydown="if(event.keyCode==13)event.keyCode=9" />
6.只能為數字(有閃動)
<input type="text" nkeyup="value=value.replace(/[^"d]/g,'') " nbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^"d]/g,''))" />
7.只能為數字(無閃動)
<input type="text" style="ime-mode:disabled" nkeydown="if(event.keyCode==13)event.keyCode=9" nkeypress="if ((event.keyCode<48 || event.keyCode>57)) event.returnValue=false" />
8.只能輸入英文和數字(有閃動)
<input type="text" nkeyup="value=value.replace(/["W]/g,'')" nbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^"d]/g,''))" />
9.遮蔽輸入法
<input type="text" name="url" style="ime-mode:disabled" nkeydown="if(event.keyCode==13)event.keyCode=9" />
10. 只能輸入 數字,小數點,減號(-) 字元(無閃動)
<input nkeypress="if (event.keyCode!=46 && event.keyCode!=45 && (event.keyCode<48 || event.keyCode>57)) event.returnValue=false" />
11. 只能輸入兩位小數,三位小數(有閃動)
<input type="text" maxlength="9" nkeyup="if(value.match(/^"d{3}$/))value=value.replace(value,parseInt(value/10)) ;value=value.replace(/"."d*"./g,'.')" nkeypress="if((event.keyCode<48 || event.keyCode>57) && event.keyCode!=46 && event.keyCode!=45 || value.match(/^"d{3}$/) || /"."d{3}$/.test(value)) {event.returnValue=false}" />
評價已經被關閉 | 目前有 0 個人評價 |
好 50% (0) |
不好 50% (0) |
HTML標準的RFC
type
Used to set the type of input field:
type=text (the default)
A single line text field whose visible size can be set using the size attribute, e.g. size=40 for a 40 character wide field. Users should be able to type more than this limit though with the text scrolling through the field to keep the input cursor in view. You can enforce an upper limit on the number of characters that can be entered with the maxlength attribute. The name attribute is used to name the field, while the value attribute can be used to initialize the text string shown in the field when the document is first loaded.
<input type=text size=40 name=user value="your name">
type=password
This is like type=text, but echoes characters using a character like * to hide the text from prying eyes when entering passwords. You can use size and maxlength attributes to control the visible and maximum length exactly as per regular text fields.
<input type=password size=12 name=pw>
type=checkbox
Used for simple Boolean attributes, or for attributes that can take multiple values at the same time. The latter is represented by several checkbox fields with the same name and a different value attribute. Each checked checkbox generates a separate name/value pair in the submitted data, even if this results in duplicate names. Use the checked attribute to initialize the checkbox to its checked state.
<input type=checkbox checked name=uscitizen value=yes>
type=radio
Used for attributes which can take a single value from a set of alternatives. Each radio button field in the group should be given the same name. Radio buttons require an explicit value attribute. Only the checked radio button in the group generates a name/value pair in the submitted data. One radio button in each group should be initially checked using the checked attribute.
<input type=radio name=age value="0-12">
<input type=radio name=age value="13-17">
<input type=radio name=age value="18-25">
<input type=radio name=age value="26-35" checked>
<input type=radio name=age value="36-">
type=submit
This defines a button that users can click to submit the form's contents to the server. The button's label is set from the value attribute. If the name attribute is given then the submit button's name/value pair will be included in the submitted data. You can include several submit buttons in the form. See type=image for graphical submit buttons.
<input type=submit value="Party on ...">
type=image
This is used for graphical submit buttons rendered by an image rather than a text string. The URL for the image is specified with the src attribute. The image alignment can be specified with the align attribute. In this respect, graphical submit buttons are treated identically to IMG elements, so you can set align to left, right, top, middle or bottom. The x and y values of the location clicked are passed to the server: In the submitted data, image fields are included as two name/value pairs. The names are derived by taking the name of the field and appending ".x" for the x value, and ".y" for the y value.
Now choose a point on the map:
<input type=image name=point src="map.gif">
Note: image fields typically cause problems for text-only and speech-based user agents!
type=reset
This defines a button that users can click to reset form. fields to their initial state when the document was first loaded. You can set the label by providing a value attribute. Reset buttons are never sent as part of the form's contents.
<input type=reset value="Start over ...">
type=file
This provides a means for users to attach a file to the form's contents. It is generally rendered by text field and an associated button which when clicked invokes a file browser to select a file name. The file name can also be entered directly in the text field. Just like type=text you can use the size attribute to set the visible width of this field in average character widths. You can set an upper limit to the length of file names using the maxlength attribute. Some user agents support the ability to restrict the kinds of files to those matching a comma separated list of MIME content types given with the ACCEPT attribute e.g. accept="image/*" restricts files to images. Further information can be found in RFC 1867.
<input type=file name=photo size=20 accept="image/*">
type=hidden
These fields should not be rendered and provide a means for servers to store state information with a form. This will be passed back to the server when the form. is submitted, using the name/value pair defined by the corresponding attributes. This is a work around for the statelessness of HTTP. Another approach is to use HTTP "Cookies".
<input type=hidden name=customerid value="c2415-345-8563">
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12639172/viewspace-462653/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- <input type="file"> 限制檔案型別型別
- input file控制元件限制上傳檔案型別控制元件型別
- JavaScript input type=file 獲取檔案大小及型別限制JavaScript型別
- input file簡單實現限制上傳檔案的型別型別
- input的type值型別和描述-HTML型別HTML
- $(":input")和$("input")區別
- el-input 限制number型別,輸入中文,游標不垂直居中問題型別
- 征服number型別的input框型別
- input和textarea區別
- input和:input選擇器的區別
- struts2檔案上傳型別限制 之 zip和rar檔案型別型別
- jQuery匹配指定type型別input元素jQuery型別
- input事件和change事件區別事件
- input最大長度限制問題
- rman 中的 delete all input 和 delete input 的區別delete
- PLSQL Language Reference-PL/SQL資料型別-SQL資料型別-有限制的子型別SQL資料型別
- Python2 中 input() 和 raw_input() 的區別Python
- HTML5新增的input型別程式碼演示HTML型別
- input:file上傳型別控制簡單介紹型別
- HTML5的input:file上傳型別控制HTML型別
- <button>和<input type=“button“> 的區別
- <input type="button">和<button>的區別
- latex中\input和\include的區別
- 值型別和引用型別型別
- HTML5的 input:file上傳以及型別控制HTML型別
- 修改input標籤type=file型別按鈕的值型別
- JavaScript值型別和引用型別JavaScript型別
- Date型別和Regex型別型別
- Swift值型別和引用型別Swift型別
- 型別預設和any型別型別
- js基本型別和引用型別區別JS型別
- 關於mysql varchar 型別的最大長度限制MySql型別
- oracle下,要更改資料型別時的限制Oracle資料型別
- 微信小遊戲開發(5)-全域性物件和檔案限制型別遊戲開發物件型別
- jquery 中$("form :input") $("form input") 區別jQueryORM
- raw_input() 與 input()的區別
- Java的基本型別和引用型別Java型別
- typeScript 型別斷言、聯合型別和交叉型別(七)TypeScript型別