宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
1、选中去除文本框文字,离开后显示原有文字:
< input name = "key" type = "text" id = "key" value = "关键词" size = "30"
onmouseover = this .focus();this.select();
onclick = "if(value==defaultValue){value='';this.style.color='#000'}"
onBlur = "if(!value){value=defaultValue;this.style.color='#999'}" style = "color:#999" />
2、选中后方可编辑:
< input type = "checkbox" name = "tpbox" value = "1" onclick = "if(this.checked) {txtNo.disabled=false}else{txtNo.disabled=true}" >你一定要幸福,我会好好的!
你的姓名:< input type = "text" name = "txtNo" size = "20" value = "选中前面的选项方可编辑" disabled>
3、点击链接后方可编辑:
< a href = "#" onclick = "username.readOnly=false;alert('你好,欢迎使用!')" >先点击我哦!</ a >
你的姓名:< input id = "username" value = "--请输入--" size = "30" readOnly>
4、输入框从中间输入:从中间输入:
< input type = "text" name = "mid" style = "text-align:center;" >
5、输入框变色:输入框改变变色:
< input type = "text" size = "20" style = " border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.1em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; auto !important; box-sizing: content-box !important; font-size: 1em !important; min-height: auto !important; white-space: pre !important; background-image: none !important; background-attachment: initial !important; background-size: initial !important; background-origin: initial !important; background-clip: initial !important; background-position: initial !important; background-repeat: initial !important;"> onfocus = "style.backgroundColor='#FFFF00'"
onblur = "style.backgroundColor='#FFFFFF'" >
6、输入框只能输入数字(用的是正则表达式):你 的年龄:
< input onkeyup = "value=value.replace(/[^d]/g,'') "
onbeforepaste = "clipboardData.setData('text',clipboardData.getData('text').replace(/[^d]/g,''))" >
7、输入框只能输入中文(用的是正则表达式):你的中文名:
< input onkeyup = "value=value.replace(/[ -~]/g,'')" onkeydown = "if(event.keyCode==13)event.keyCode=9" >
8、只能输入英文和数字(用的是正则表达式):
你 的昵称:< input onkeyup = "value=value.replace(/[W]/g,'') "
onbeforepaste = "clipboardData.setData('text',clipboardData.getData('text').replace(/[^d]/g,''))"
onkeydown = "if(event.keyCode==13)event.keyCode=9" >
9、输入框不能编辑,但表单可以获得输入框内的值:
< input type = "text" value = "afreon" onclick = "alert('总和不能编辑!');" onfocus = "this.blur()" />
< input type = "text" value = "afreon" onclick = "alert(this.value);" readonly />
< input value = "不可修改" readonly = "true" type = "text" />//:字体颜色为黑体
10、输入框不能编辑,并且表单不能获得输入框内的值
< input value = "不可修改" disabled = "disabled" type = "text" />//:字体颜色为灰体
11、输入框禁止输入法:
< input onpaste = "return false" style = "ime-mode:disabled" >
来源:http://www.yoodb.coom
|