posted on June 26 Show version history

Hey All,

Page-by-page validation is something I've always played around with, and typically I end up creating my own nav buttons because I prefer to have each page validated before letting the user continue.

However, I just started experimenting with parsley validation groups, and so far it seems to be doing what I want even with the built-in navigation buttons.

I have only just started testing this out, but I'd thought I'd share in case anyone was interested, or knows more about parsley and can point out a better way to do this.

$(document).ready(function(){
  // assign validation groups based on page
  $('.cf-page').each(function(index){
    $(this).find(':input').attr('data-parsley-group',$(this).prop('id'));
  });
  
  // validate page group
  $('.cf-next-btn').on('click',function(){
    var g = $(this).data('parsley-group');
    $('.cf-form').parsley().validate({group: g});
  });
});

Again, I only just started messing with this so there may be issues I haven't run into yet, but I wanted to share it anyway because I think this is something that is sorely needed in Forms.

4 0