input type 有哪些. 分别是什么意思
4个回答
展开全部
常用限制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" onkeydown="if(event.keyCode==13)event.keyCode=9" />
5.只能为中文(有闪动)
<input type="text" onkeyup="value=value.replace(/[ -~]/g,'')" onkeydown="if(event.keyCode==13)event.keyCode=9" />
6.只能为数字(有闪动)
<input type="text" onkeyup="value=value.replace(/[^\d]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" />
7.只能为数字(无闪动)
<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.只能输入英文和数字(有闪动)
<input type="text" onkeyup="value=value.replace(/[\W]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" />
9.屏蔽输入法
<input type="text" name="url" style="ime-mode:disabled" onkeydown="if(event.keyCode==13)event.keyCode=9" />
10. 只能输入 数字,小数点,减号(-) 字符(无闪动)
<input onkeypress="if (event.keyCode!=46 && event.keyCode!=45 && (event.keyCode<48 || event.keyCode>57)) event.returnValue=false" />
11. 只能输入两位小数,三位小数(有闪动)
<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}" />
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" onkeydown="if(event.keyCode==13)event.keyCode=9" />
5.只能为中文(有闪动)
<input type="text" onkeyup="value=value.replace(/[ -~]/g,'')" onkeydown="if(event.keyCode==13)event.keyCode=9" />
6.只能为数字(有闪动)
<input type="text" onkeyup="value=value.replace(/[^\d]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" />
7.只能为数字(无闪动)
<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.只能输入英文和数字(有闪动)
<input type="text" onkeyup="value=value.replace(/[\W]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" />
9.屏蔽输入法
<input type="text" name="url" style="ime-mode:disabled" onkeydown="if(event.keyCode==13)event.keyCode=9" />
10. 只能输入 数字,小数点,减号(-) 字符(无闪动)
<input onkeypress="if (event.keyCode!=46 && event.keyCode!=45 && (event.keyCode<48 || event.keyCode>57)) event.returnValue=false" />
11. 只能输入两位小数,三位小数(有闪动)
<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}" />
展开全部
http://www.w3.org/TR/REC-html32.html
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.
<p>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">
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.
<p>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">
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
常用限制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"
onkeydown="if(event.keyCode==13)event.keyCode=9"
/>
5.只能为中文(有闪动)
<input
type="text"
onkeyup="value=value.replace(/[
-~]/g,'')"
onkeydown="if(event.keyCode==13)event.keyCode=9"
/>
6.只能为数字(有闪动)
<input
type="text"
onkeyup="value=value.replace(/[^\d]/g,'')
"
onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"
/>
7.只能为数字(无闪动)
<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.只能输入英文和数字(有闪动)
<input
type="text"
onkeyup="value=value.replace(/[\W]/g,'')"
onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"
/>
9.屏蔽输入法
<input
type="text"
name="url"
style="ime-mode:disabled"
onkeydown="if(event.keyCode==13)event.keyCode=9"
/>
10.
只能输入
数字,小数点,减号(-)
字符(无闪动)
<input
onkeypress="if
(event.keyCode!=46
&&
event.keyCode!=45
&&
(event.keyCode<48
||
event.keyCode>57))
event.returnValue=false"
/>
11.
只能输入两位小数,三位小数(有闪动)
<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}"
/>
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"
onkeydown="if(event.keyCode==13)event.keyCode=9"
/>
5.只能为中文(有闪动)
<input
type="text"
onkeyup="value=value.replace(/[
-~]/g,'')"
onkeydown="if(event.keyCode==13)event.keyCode=9"
/>
6.只能为数字(有闪动)
<input
type="text"
onkeyup="value=value.replace(/[^\d]/g,'')
"
onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"
/>
7.只能为数字(无闪动)
<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.只能输入英文和数字(有闪动)
<input
type="text"
onkeyup="value=value.replace(/[\W]/g,'')"
onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"
/>
9.屏蔽输入法
<input
type="text"
name="url"
style="ime-mode:disabled"
onkeydown="if(event.keyCode==13)event.keyCode=9"
/>
10.
只能输入
数字,小数点,减号(-)
字符(无闪动)
<input
onkeypress="if
(event.keyCode!=46
&&
event.keyCode!=45
&&
(event.keyCode<48
||
event.keyCode>57))
event.returnValue=false"
/>
11.
只能输入两位小数,三位小数(有闪动)
<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}"
/>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这么强
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询