11个html文本框效果,经常会用到。
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="background-color:#FFFFFF" 
  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">