Need jquery Validation help to make it wirth with jquery UI submission
Hi Experts I need your help in fixing up my jquery UI form submission validation to work with jquery Validation Plugin. Currently the Jquery UI code i am using for submission is the below:
submitUsers = function() { $('#tabs_users>#ui-tabs-2').on('click', '.submitusers', function() { var dataString = $("form").serialize(); $.ajax({ type: "POST", url: "save.cfm?mode=useraction" + '&submission=' + Math.random(), cache: false, data: dataString, success: function(result) { var i = result; $('#tabs_users>#ui-tabs-2').off('click', '.submitusers'); if ($.trim(i) == 'Warning! Country with Same Name already Exists' || $.trim(i) == 'Warning! Code for the Entered Country Exists for another Country' || $.trim(i) == 'Warning! Code and Country already Exists') { $("#AddCountry").html(result).addClass('text-warning'); $("#AddCountry").addClass('text-warning').fadeIn("slow"); setTimeout(function() { $("#AddCountry").addClass('text-warning').fadeOut("slow"); }, 3000); } else if ($.trim(i) == 'Cool! Processed Successfully') { $("#AddCountry").html(result).addClass('text-success'); $("#AddCountry").addClass('text-success').fadeIn("slow"); setTimeout(function() { $("#AddCountry").addClass('text-success').fadeOut("slow"); }, 3000); } else { $("#AddCountry").html(result).addClass('text-error'); $("#AddCountry").addClass('text-error').fadeIn("slow"); setTimeout(function() { $("#AddCountry").addClass('text-error').fadeOut("slow"); }, 3000); } } }); });}
Thanks, I was trying with this plugin, But my question is:
1. where i add this, when i am doing the on click event of the function or before
2. how can i stop its processing unless all errors has been cleared.
darren-w-
add it before,
on keyup call $("#adduser").valid() this will return T/F and then based on this enable/disable the submit button
Coast Line
ASKER
i want to have validation on submit of the Page, not on keyup. anyways, i am still looking for solution. Thanks anyways, when i do it, i will post the answer here
Thanks, But it is going in both the commands, if and the lese too untitled.GIF
mcnute
You're doing a validation in your ajax with code that's coming from the server side. So it is not possible to validate data which is processed by the server without submitting the form.
What you can do is to populate the form with the primary submitted values stored in your i variable and sent that back to the form when thir first if clause and or the else is true.
Or:
What would make more sense is to submit that form to the same page the form is on (without ajax involved) and on the server side redirect to a success page if data was alright, or just stay on the original form page and 'paste' original input values in the form, so the user doesn't have to input it again and display error messages accordingly.
What have you tried so far?
Darren