T
Tornadoman
Подскажите кто нибудь))) Что в коде не правильно? Не работает jQuery.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Form of registration</title>
<style type="text/css">
label.error {
color:#FF000;
font-size:12px;
}
input.error {
border:1px dotted #f00;
}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#form').validate({
rules:{
email:{
required:true,
email:true
minlength:6,
maxlength:25
},
password:{
required:true,
minlength:6,
maxlength:25
},
password_confirm:{
required:true,
minlength:6,
maxlength:25,
equalTo:"#password"
},
name:{
required:true,
minlength:2,
maxlength:20
},
lastname:{
required:true,
minlength:2,
maxlength:20
},
gender:"required"
},
});
messages:{
email:{
requered:"Pleas enter your valid email address",
email:"Pleas enter your valid email address",
},
password:{
required: "Provide a password",
rangelength:"Enter at least {0} characters"
},
password_confirm: {
required: "Repeat your password",
minlength: "Enter at least {0} characters",
equalTo: "Enter the same password as above"
},
name:"Enter your name",
lastname:"Enter your lastname",
gender:"Choose your gender",
},
});
});
</script>
</head>
<body>
<?php echo $this->validation->error_string; ?>
<h1>Registration</h1>
<form method="post" action="/index.php/form/" name="form">
<p><label for="email">Email:</label> <br><?php $this->validation->email_error; ?><input type="text" name="email" value="<?php $this->validation->email;?>"></p>
<p><label for="password">Password:</label> <br><?php $this->validation->password_error; ?><input type="password" name="password" value="<?php $this->validation->password;?>"></p>
<p><label for="password_confirm">Re-type password: </label> <br><?php $this->validation->passconf_error; ?><input type="password" name="passconf" value="<?php $this->validation->passconf;?>"></p>
<p><label for="name">Name:</label> <br><?php $this->validation->name_error; ?><input type="text" name="name" value="<?php $this->validation->name;?>"></p>
<p><label for="last_name">Last name:</label> <br><?php $this->validation->lastname_error; ?><input type="text" name="lastname" value="<?php $this->validation->lastname;?>"></p>
<p><label for="gender">Your gender:</label> <br><label><input type="radio" name="gender" value="yes">Male</label> <br><label><input type="radio" name="gender" value="no">Female</label></p>
<p><label for="submit"><input type="submit" name="submit" value="Submit"></label></p>
</form>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Form of registration</title>
<style type="text/css">
label.error {
color:#FF000;
font-size:12px;
}
input.error {
border:1px dotted #f00;
}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('#form').validate({
rules:{
email:{
required:true,
email:true
minlength:6,
maxlength:25
},
password:{
required:true,
minlength:6,
maxlength:25
},
password_confirm:{
required:true,
minlength:6,
maxlength:25,
equalTo:"#password"
},
name:{
required:true,
minlength:2,
maxlength:20
},
lastname:{
required:true,
minlength:2,
maxlength:20
},
gender:"required"
},
});
messages:{
email:{
requered:"Pleas enter your valid email address",
email:"Pleas enter your valid email address",
},
password:{
required: "Provide a password",
rangelength:"Enter at least {0} characters"
},
password_confirm: {
required: "Repeat your password",
minlength: "Enter at least {0} characters",
equalTo: "Enter the same password as above"
},
name:"Enter your name",
lastname:"Enter your lastname",
gender:"Choose your gender",
},
});
});
</script>
</head>
<body>
<?php echo $this->validation->error_string; ?>
<h1>Registration</h1>
<form method="post" action="/index.php/form/" name="form">
<p><label for="email">Email:</label> <br><?php $this->validation->email_error; ?><input type="text" name="email" value="<?php $this->validation->email;?>"></p>
<p><label for="password">Password:</label> <br><?php $this->validation->password_error; ?><input type="password" name="password" value="<?php $this->validation->password;?>"></p>
<p><label for="password_confirm">Re-type password: </label> <br><?php $this->validation->passconf_error; ?><input type="password" name="passconf" value="<?php $this->validation->passconf;?>"></p>
<p><label for="name">Name:</label> <br><?php $this->validation->name_error; ?><input type="text" name="name" value="<?php $this->validation->name;?>"></p>
<p><label for="last_name">Last name:</label> <br><?php $this->validation->lastname_error; ?><input type="text" name="lastname" value="<?php $this->validation->lastname;?>"></p>
<p><label for="gender">Your gender:</label> <br><label><input type="radio" name="gender" value="yes">Male</label> <br><label><input type="radio" name="gender" value="no">Female</label></p>
<p><label for="submit"><input type="submit" name="submit" value="Submit"></label></p>
</form>
</body>
</html>