This is my script now.

<script type="text/javascript">
$(document).ready(function() {
                                         
        $('#testForm').bind('submit', function() {
                $(this).validate(validation_options);
                
                        var valid = $(this).valid();
                        
                if (valid) {
                        
                        var queryString = $('#testForm').formSerialize();
                        //alert(queryString);
                        $(this).ajaxSubmit({
                                type:                   'post',
                                url:
'/manage/experiences/edit/123',
                                data:                   queryString,
                                target:                 '#testUpdate',
                                success:        afterEffects
            });
                        
                        return false;
                }

        });

function afterEffects ()
        {
                                        $.fn.colorbox.close();
        }
var validation_options = {
  // set your options here
  rules: {
    field: "required"
  }

};
});
</script> 

When I hit submit it tries to access the url by the browser.

Check the net activity and see

_method PUT
data[Experience][city]  LosAngeles
data[Experience][country_id]    38
data[Experience][finished]      2007
data[Experience][position]      Customer Service Rep
data[Experience][respons]       sweet sfffffffffffffffffffffffffffff
data[Experience][start] 1975
data[Experience][state_id]      15
field   

Nothing is working.

Ideas?

Dave

-----Original Message-----
From: James [mailto:james.gp....@gmail.com] 
Sent: October-02-09 12:19 AM
To: jQuery (English)
Subject: [jQuery] Re: Ajax / Form Validation


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