jquery账号验证
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/jquery-1.11.0.js" ></script>
<style>
span{
color: red;
}
</style>
<script type="text/javascript">
$(document).ready(function(){
$("#but1").click(function(){
$(".texts").each(function(){
var $ts="不能为空";
if($(this).val()==""){
$(this).next().replaceWith("<span>"+$(this).attr("xx")+$ts+"</span>")
}else{
$(this).next().replaceWith("<span>* </span>")
}
})
})
});
</script>
</head>
<body>
<form >
<table border="1">
<tr><td colspan="2" style="text-align: center;">会员注册</td></tr>
<tr>
<td>用户名</td>
<td><input type="text" xx="用户名" class="texts"><span>*</span></td>
</tr>
<tr>
<td>密码</td>
<td><input type="text" xx="密码" class="texts"><span>*</span></td>
</tr>
<tr>
<td>性别</td>
<td>
<select>
<option>男</option>
<option>女</option>
</select>
</td>
</tr>
<tr>
<td>真实姓名</td>
<td><input type="text" xx="真实姓名" class="texts"><span>*</span></td>
</tr>
<tr>
<td>邮箱</td>
<td><input type="text" xx="邮箱" class="texts"><span>*</span></td>
</tr>
<tr>
<td>eail</td>
<td><input type="text" xx="eail" class="texts"><span>*</span></td>
</tr><tr>
<td>详细住址</td>
<td><textarea class="texts" xx="详细住址" ></textarea><span>*</span></td>
</tr>
<tr>
<td colspan="2" style="text-align: center;">
<input type="button" id="but1" value="添加" />
<input type="reset" value="重置" />
</td>
</tr>
</table>
</form>
</body>
</html>
动动你发财的小手指,举手之劳,赞有余香!