How to seperate the selialized data in jquery

I got the form values using the $(this).closest("#myForm").serialize();

But here, I need to validate the values and then pass it to ajax.

i.e; my serialize() returns revw_desc & revw_tle drom this values I need to validate like,

    if(revw_tle.val().length <= 0 && revw_desc.val().length <= 0 ){
          $('.tle_error').fadeIn();
          $('.desc_error').fadeIn();
    }
    else{
            $('.tle_error').fadeOut();
            $('.desc_error').fadeOut();
            it calls AJAX..
    }

How should I do this..Is there anyother ways!!!..

Can anyone help me..

Answers 1

  • Try

    if($("#myForm").find('[name=revw_tle]').val().length <= 0 && $("#myForm").find('[name=revw_tle]').val().length <= 0 ){
          $('.tle_error').fadeIn();
          $('.desc_error').fadeIn();
    }
    else{
            $('.tle_error').fadeOut();
            $('.desc_error').fadeOut();
            it calls AJAX..
    }
    

    note: you may have a problem with the id of the form if you have multiple forms


Related Articles