I am learning jQuery right now and am looking to validate form fields with it.
The registration form in question is at http://taehee.pumpl.com/register.php
The basic code for the form field I made is:
<div id="register">
<form action="">
<fieldset>
<legend>Register</legend>
<ol>
<li><label for="username">유저네임</label>
<input id="username" name="username" size="32" type="text" ></li>
<li><label for="email">이메일</label>
<input id="email" name="email" size="32" type="text"></li>
<li><label for="password">비밀번호</label>
<input id="password" name="password" size="32" type="password"></li>
<li><label for="password2">비밀번호 확인</label>
<input id="password2" name="password2" size="32" type="password"></li></li>
</ol>
</fieldset>
<input type="submit" value="Submit">
</form>
</div> <!-- register -->
I've loaded jQuery in the header using the following:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
I also created a script with the following code:
$('#register').validate({
rules: {
username: {
required: true,
},
email: {
required: true,
email: true
},
password: {
minlength: 4,
required: true
},
password2: {
equalTo: "#password"
}
},
success: function(label) {
label.text('OK!').addClass('valid');
}
});
Unfortunately, it doesn't seem to work. I fill out the form and it doesn't matter whether the fields are all wrong.
Can anyone help me? Thank you!