在用CI框架实现注册功能时,要用JQuery进行验证,验证两次输入的密码是否相同,用户名是否已经存在
<html>
<head>
<title></title>
<script type="text/javascript" src="../js/jquery-1.4.3.js"></script>
<script type="text/javascript" language="javascript">
var nameFlag=false;
$(function(){
$("#v_pwd").blur(function(){
var pwd=$("#pwd").val();
var v_pwd=$(this).val();
if(pwd==v_pwd){
$("#pwdMsg").text("输入正确");
$("#pwdMsg").addClass("required");
nameFlag=true;
}else{
$("#pwdMsg").text("两次密码必须相同!");
$("#pwdMsg").removeClass("required");
nameFlag=false;
return;
}
});
});
</script>
</head>
<body>
<div style="background-color: blue;color:white;
text-align: center;font-size: 30px" ></div>
<p >注册信息(*为必填项)</p>
<form name="register" action=
"http://dev.test.cn/index.php/user/create"
id="register" method="post">
<table >
<tr>
<td>用户名:</td>
<td><input type="text" name="name"
id="name" /><span id="nameMsg" class="reqiired"></span></td>
</tr>
<tr>
<td>密码:</td>
<td><input type="password" name="pwd"
id="pwd" /></td>
</tr>
<tr>
<td>验证密码:</td>
<td><input type="password" name="v_pwd"
id="v_pwd" /><span id="pwdMsg" class="required"></span></td>
</tr>
<tr>
<td>性别:</td>
<td><input type="text" name="sex"
id="sex" /></td>
</tr>
<tr>
<td>email:</td>
<td><input type="text" name="email"
id="email" /></td>
</tr>
<tr>
<td>联系电话:</td>
<td><input type="text" name="phone"
id="phone" /></td>
</tr>
<tr>
<td>地址:</td>
<td><input type="text" name="address"
id="address" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit"
id="submit" value="提交"/>
<input type="button" name="return"
onclick="javascript:history.back();"
value="返回"/></td>
</tr>
</table>
</form>
</body>
</html>
上面写的JS老是不出现验证效果,到底哪里错了,和求个用户名已存在的AJax,求高手解答
|