Here's a simplified version of what you want to do:

$('#testForm').bind('submit', function() {
    $(this).validate(validation_options);
    var valid = $(this).valid();
    if (valid) {
        // do your ajax
    }
});

var validation_options = {
  // set your options here
};

On Oct 1, 10:52 am, "Dave Maharaj :: WidePixels.com"
<d...@widepixels.com> wrote:
> I have a form that gets submitted via AJAX, now i want to add the validation
> but cant make sense of it.
> Using malsup form script to submit,
>
> Now I would like to incorporate the jQuery Validation Plug-in found 
> onhttp://jquery.bassistance.de/validate/demo/index.html
>
> I currently have this so submit:
>
> <script type="text/javascript">
> $(document).ready(function() {
>  $('#testForm').live("click", function(){
>   $('#testForm').bind('submit', function() {
>    var queryString = $('#testForm').formSerialize();
>    var id = '<?php echo $id; ?>';
>
>     $(this).ajaxSubmit({
>         type:    'post',
>            url:      '/manage/experiences/edit/123',
>         data:     queryString,
>       target:   '#updateMe',
>     success:     afterEffects
>             });
>
>   return false;
>   });
>  });
>
>  function afterEffects ()
>  {
>      $.fn.colorbox.close();
>  }
>
> })
>
> </script>
>
> But how do I add in the validation script into this? Any help would be
> greatly appreciated.
>
> Thanks
>
> Dave

Reply via email to