用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字

用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字

请选择技术分类

 *如果你找不到更细的分类,可以选择上级分类
当前位置:云代码 - 技术问答 - Eclipse

想给表单加一个check但是照着葫芦画瓢没反应

 悬赏:10|提问者:named李由|浏览:2297
举报|2013-11-27
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>校验</title>
<link rel="stylesheet" type="text/css"href="yz.css"/>
<script type="text/javascript"src="js/jquery-1.8.2.min.js"></script>
<script type="text/javascript">


$(document).ready(function() {
//创建一个*
  $(".a1").each(function(){
    
   var hdv=$("<strong  class='redcolor'>*</strong>");
   
    $(this).parent().append(hdv);
    
    });
//结束

//判断
$('form:input').blur(function(){
$(this).parent().find(".a2").remove();
if($(this).is('#username')){

   if(this.value==""||this.value.length<6){
      var hdv1=$('<span  class="a2">用户名不能小于6位</span>');
      $(this).parent().append(hdv1);
   }else{
   var hdv1=$('<span  class="a2">正确</span>');
       $(this).parent().append(hdv1);
   }
}
});

});

</script>

</head>

<body>
<form method="post" action="">
<div class="one">
<label name="username">用户名:</label>
<input type="text"id="username" class="a1"/>
</div>

<div class="one">
<label for="password">密码:</label>
<input type="password"id="password" class="a1"/>
</div>
<div class="one">
<label for="password1">确认密码:</label>
<input type="password"id="password1" class="a1"/>
</div>
<div class="one">
<label for="email">邮箱:</label>
<input type="text"id="email" class="a1"/>
</div>
<div class="one">
<label for="tel">手机:</label>
<input type="text"id="tel" class="a1"/>
</div>

<div class="two">
<input type="submit" id="send"value="提交">
<input type="reset" id="res"value="重置">
</div>
</form>
</body>
</html>

css代码


*{padding:0;margin:0;}
body{font-size:12px;padding:100px;}
.one{margin:10px 0;}
.one label{width:100px;float:left;text-align:right;height:20px;line-height:20px;}
.one input{border:1px  solid #0F0;height:20px;}
.two{padding-left:100px;}
.redcolor{color:#C03;}



我来回答

所有回答
举报|(2)|(1)2013-12-01
要确保js/jquery-1.8.2.min.js存在,就是说同级目录的js目录里要有这个jquery库文件。
举报|(1)|(2)2014-01-11
要确保js/jquery-1.8.2.min.js存在,就是说同级目录的js目录里要有这个jquery库文件。
举报|(2)|(2)2014-02-12
<script type="text/javascript"src="js/jquery-1.8.2.min.js"></script>

要确保js/jquery-1.8.2.min.js存在,就是说同级目录的js目录里要有这个jquery库文件。如果没有不能跑

举报|(1)|(2)2014-03-12
要确保js/jquery-1.8.2.min.js存在,就是说同级目录的js目录里要有这个jquery库文件。
举报|(1)|(2)2014-05-29
0.0
举报|(1)|(2)2014-07-18

学习

举报|(1)|(1)2017-04-18
??
举报|(1)|(1)2017-08-24
6
举报|(1)|(1)2018-11-28
大声地说
举报|(1)|(1)2019-07-30
111

相关提问