私のプロジェクトの例:
function initContactForm(){
$('#contact-form').validate({
errorClass: 'invalid-input',
validClass: 'valid-input',
debug: false,
rules: {
name: {
required: true,
minlength: 3
},
sername: {
required: true,
minlength: 3
},
company_name: {
required: true,
minlength: 3
},
phone: {
required: true,
digits: true,
minlength: 7
},
mail: {
required: true,
email: true
},
message: {
required: true,
minlength: 20
}
},
submitHandler: function(data){
$('#loading').ajaxStart(function(){
$(this).show('fast');
$('.register-btn').hide('fast');
});
$('#loading').ajaxStop(function(){
$(this).hide('fast')
});
$('#contact-form').ajaxSubmit(function(html){
$('.control-group').animate({ opacity: 0.2 }, 500, function(){ opacity: 1 });
$('#formHandler').html(html);
$('#formHandler').show('fast');
$('.alert').bind('close', function(){
$('#contact-form').each(function(){ this.reset(); });
$('.controls input').removeClass();
$('.controls textarea').removeClass();
$('.register-btn').show('fast');
$('.control-group').animate({ opacity: 1 }, 500, function(){ opacity: 0.2 });
});
});
}
});
}