纯复习,在$(this).val()这里浪费了时间,val()只适合input里面的value值,如果是span等标签里包裹的文本要用text()!!

 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="jquery.js"></script>
<style>
table{
/*width: 500px;*/
height: 200px;
border-collapse: collapse;
border-color: #f00;
}
td{
border: 1px solid #00f;
}
td:nth-child(1){
width: 100px;
}
td:nth-child(2){
width: 200px;
} td:nth-child(3){
border: 0px;
display: none;
}
</style>
</head>
<body>
<form id="form1" action="regist.php" method="get">
<table >
<tr>
<td>用户名</td>
<td><input type="text" name="username">
<!-- <span>hahahahah</span> -->
</td>
<td><span>用户名至少6位!</span></td> </tr>
<tr>
<td>密码</td>
<td><input type="text" name="password"></td>
<td><span>密码至少6位!</span></td>
</tr>
<tr>
<td>重复密码</td>
<td><input type="text" name="repassword"></td>
<td><span>两次密码不一致!</span></td>
</tr>
<tr>
<td>手机</td>
<td><input type="text" name="phone"></td>
<td><span>手机号格式不正确!</span></td>
</tr>
<tr>
<td>邮箱</td>
<td><input type="text" name="email"></td>
<td><span>邮箱格式不正确!</span></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="提交"></td>
</tr> </table>
</form>
</body>
<script>
var check1=check2=check3=check4=check5=0;
$('[name=username]').blur(function(){
if ($(this).val().length<6) {
$(this).parent().next().show();
check1 = 0;
}else{
$(this).parent().next().hide();
check1 = 1;
}
});
$('[name=password]').blur(function(){
if ($(this).val().length<6) {
$(this).parent().next().show();
check2 = 0;
}else{
$(this).parent().next().hide();
check2 = 1;
}
});
$('[name=repassword]').blur(function(){
if ($(this).val()!=$('[name=password]').val()) {
$(this).parent().next().show();
check3 = 0;
}else{
$(this).parent().next().hide();
check3 = 1;
}
});
$('[name=phone]').blur(function(){
if (!$(this).val().match(/^188\d{8}$/)) {
$(this).parent().next().show();
check4 = 0;
}else{
$(this).parent().next().hide();
check4 = 1;
}
});
$('[name=email]').blur(function(){
if (!$(this).val().match(/^\w+\@\w+\.com$/)) {
$(this).parent().next().show();
check5 = 0;
}else{
$(this).parent().next().hide();
check5 = 1;
}
}); $('#form1').submit(function(){
$('input').blur();
var sum = check1+check2+check3+check4+check5;
if(sum!=5){
return false;
} });
</script>
</html>

最新文章

  1. 如何动态在文档中加入<script></script>写入大段js?
  2. python中常用的模块的总结
  3. C#根据身份证号码,计算生日、年龄、性别
  4. 根据IP获取省市 .
  5. PAT_1010 一元多项式求导
  6. SGU 294 He&#39;s Circles
  7. 2014第一周五开发问题记URL传参乱码等
  8. Java钉钉开发_02_免登授权(身份验证)(附源码)
  9. 3_Longest Substring Without Repeating Characters -- LeetCode
  10. 芝麻HTTP:爬虫的基本原理
  11. Headless Chrome:服务端渲染JS站点的一个方案【中篇】【翻译】
  12. Linux-Kconfig总结与分析
  13. Codeforces Round #539--1113B - Sasha and Magnetic Machines
  14. checkpoint-BLCR部署和测试(源码)
  15. Vue + Element UI 实现权限管理系统 (管理应用状态)
  16. Lua函数[转]
  17. JAVA取得IP
  18. 2017-2018-1 20155330 《信息安全系统设计基础》第10周课堂测试&amp;课下作业
  19. BZOJ3462 DZY Loves Math II(动态规划+组合数学)
  20. 〖Windows〗zigbee实验之cygwin编译TestSimpleMac出错的解决方法

热门文章

  1. 用 Chrome 扩展实现修改
  2. 【转载】【Todo】电商架构相关技术分析
  3. MySQL5.6安装步骤(windows7/8_64位)
  4. python 如何调用子文件下的模块
  5. nginx 相关命令 nginx -s reload/stop/quit
  6. Swing JTable 具体解释
  7. Discuz常见小问题2-如何修改整个网站的默认字体为微软雅黑
  8. 正则表达式学习(PCRE)
  9. Codeforces Beta Round #17 C. Balance (字符串计数 dp)
  10. SQLServer:探讨EXEC与sp_executesql的区别详解