JQuery Validation

Email, Verify Email and Password, Confirm Password Validation using JQuery

<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>
<style type=”text/css”>
label.error { float: left; color: red; margin-left: 400px; vertical-align: top; margin-top:-20px; }
p { clear: both; }
.submit { margin-left: 12em; }
em { font-weight: bold; padding-right: 1em; vertical-align: top; }
.inf { font-family: verdana, sans-serif; color: #999; background: #333; border: 1px solid #505050; padding: .2em; font-size: 1em }
</style>
<script type=”text/javascript”>
SubmittingForm=function() {
//alert(“The form has been validated.”);
<? if (ofanvalid==”true”) { ?>
//alert(“valid”);
<? } else { ?>
//alert(“notvalid”);
<? } ?>
oshippingform.submit();
}
$(document).ready(function() {
$(“#oshippingform”).validate({
submitHandler:function(form) {
SubmittingForm();
},
rules: {
first_name: “required”, // simple rule, converted to {required:true}
email_address: { // compound rule
required: true,
email: true
},
email_confirm: {
required: true,
equalTo: “#email_address”
},
password: { // compound rule
required: true,
},
confirmpassword: {
required: true,
equalTo: “#password”
},
url: {
url: true
},
comment: {
required: true
}
},
messages: {
comment: “Please enter a comment.”
}
});
});
</script>

In Input type:

<INPUT type=”text” name=”email_address” id=”email_address” class=”required inf” maxlength=”40″ value=”">

That’s an example. You can modify it.

Source: http://docs.jquery.com/Plugins/Validation and http://docs.jquery.com/Plugins/Validation/validate

Tags:

This entry was posted on Monday, August 16th, 2010 at 9:10 am and is filed under PHP. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.