Focus效果的提交信息表单

时间:2015/11/1 19:42:00来源:互联网 作者:flyso 点击: 1045 次

<script>
function suckerfish(type, tag, parentId) {
if (window.attachEvent) {
window.attachEvent("onload", function() {
var sfEls = (parentId==null)?document.getElementsByTagName(tag):document.getElementById(parentId).getElementsByTagName(tag);
type(sfEls);
});
}
}
sfFocus = function(sfEls) {
for (var i=0; i<sfEls.length; i++) {
sfEls.onfocus=function() {
this.className+=" sffocus";
}
sfEls.onblur=function() {
this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
}
}
}
suckerfish(sfFocus, "INPUT");
suckerfish(sfFocus, "TEXTAREA"); 
</script>

<style type="text/css">
form{
margin: 0px auto;
width: 450px;
border: solid 1px #CCC;
}
.bo{
border-bottom: solid 1px #CCC; 
}
label{
float: left;
padding: 10px 0px 4px 30px; 
}
input{
padding: 1px; 
}
input,textarea{
border: 1px solid #CCC;
margin: 5px 0px; 
}
textarea{
padding: 2px;
}
.bt{
width: 38px;
height: 20px;
font-size: 11px;
border: solid 1px #CCC;
background: #FBFBFB;
text-align: center;
}
.btcenter{
text-align: center;
clear: left; 
padding: 4px 0px 0px;
}
.sffocus {/*----for IE----*/
background: #F0F9FB;
border: 1px solid #1D95C7;
}
textarea:focus, input:focus {/*----for firefox......----*/
background: #F0F9FB;
border: 1px solid #1D95C7;
}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #666666;
margin-top:20px;
}
</style>
<form action="#" method="post" name="myform" id="myform">
<div class="bo">
<label>姓名:</label>
<input type="text"size="20" maxlength="10" /> 
</div>
<div class="bo">
<label>电话:</label>
<input type="text" size="20" maxlength="16" />
</div>
<div class="bo">
<label>主题:</label>
<input type="text" size="30" maxlength="20" /> 

</div>
<div class="bo">
<label>内容:</label>
<textarea cols="40" rows="8"></textarea> 
</div>
<div class="btcenter">
<input type="submit" class="bt" value="Send" />

<input type="reset" class="bt" value="Reset" />
</div>
</form>

Copyright © 2005 - 2016 flyso.cn. 飞搜 版权所有 鄂ICP备11002783号-3