jnsandrew
jnsandrew

Reputation: 90

Submit form after Parsley Remote validation

When I include Parsley.Remote in my site, my forms instantly lose the ability to submit. I'm thinking this is intentional since it needs to process the async stuff first before submitting.

Problem is I can't just tell the form to submit in my done function. Is there anything I can try or is this just not possible?

$('input[type="submit"]').click(function () {
 $('form').parsley().asyncValidate()
  .done(function () { console.log("success"); $('form').submit();  })
  .fail(function () { console.log('there is an error'); });
});

Upvotes: 2

Views: 535

Answers (1)

Cheese Slice
Cheese Slice

Reputation: 11

I had the same problem and got around it by using parsley().destroy() before submitting the form. I don't know if there is an easier way to do it but this seemed to work for me.

$('input[type="submit"]').click(function () {
  $('form').parsley().asyncValidate()
     .done(function () { 
         $('form').parsley().destroy(); 
         $('form').submit();  
      })

     .fail(function () { console.log('there is an error'); });
});

Upvotes: 1

Related Questions