jquery - Parsley form always fails validation on first submit -


i have form i'm trying validate parsley this:

$('form#captainregistrationform').on('submit', function() {   var $this;   $this = $(this);   if ($this.parsley('validate')) {     console.log('yes');   } else {     console.log('no');   }   return false; }); 

unexpected behavior:

on first submit, console returns no (regardless of whether form valid or not). on second submit returns yes (if form valid).

after second submit, purposely make form wrong, on third submit, console returns yes. after press submit again returns no.

is there reliable way validate form parsley? i'm using parsley version 2.0.2

its kind of late respose.

however, not binding parsley form before submit. should this:

// bind parsley form $('form#captainregistrationform').parsley();  // on form submit, validate form $('form#captainregistrationform').on('submit', function(e) {     var $this;     $this = $(this);     if ($this.parsley('validate')) {         console.log('yes');     } else {         console.log('no');     }      e.preventdefault();     return false; }); 

assuming form exists, should have no problems this.


Comments

Popular posts from this blog

java - How to print docx and pdf? -

qml - Is it possible to implement SystemTrayIcon functionality in Qt Quick application -

c# - How to use process.StartInfo.Arguments in command prompt? -