how to integrate jquery form plugin and jquery validation plugin -
how integrate form plugin http://malsup.com/jquery/form/ , jquery validation plugin http://docs.jquery.com/plugins/validation. have been trying integrate both plugin problem form gets submitted if click button first time, if fields empty, in other words how beforesubmit overlooked. when button clicked second time the beforesubmit takes effect , validation kicked in. cant see doing wrong. can 1 point me in right direction:
$(document).ready(function () { $("#register_student_1 button").click(function (e) { var options = { target: '#reg-output1', beforesubmit: showrequest, success: showresponse, type: 'post' }; $('#register_student_1').ajaxform(options); }), function showresponse(responsetext, statustext, xhr, $form) { console.log("showresponse test"); } function showrequest(formdata, jqform, options) { $("#register_student_1").validate({ rules: { first_name: "required", last_name: "required", date_of_birth: { date: true, required: true }, address_1: "required", nationality: "required", city: "required", country: "required", email: { required: true, email: true }, current_school_name: "required", }, messages: { first_name: "please enter first name", last_name: "please enter last name", date_of_birth: "please enter date of birth", } }); } });
Comments
Post a Comment