JQuery and Colorbox Validation Plugin

Does anyone know what is the best way to run the Jquery Validation plugin when submitting a form loaded dynamically into a jQuery Colorbox modal window?

+3
source share
2 answers

Add a check configured for colorbox callback. Thus, the color field was loaded, and the form exists before you try to set up validation for it.

 $('selector').colorbox({...options...}, function() {
     $('form',this).validate( {...options...} );
 });
+6
source

I played with this and found a better solution (at least for myself).

$('selector').colorbox(
     {options, onComplete:function(){$('selector').validate({}
});

Visually, I see when the lightbox is finished, it will be attached to this function in the lightbox. This is the same as Twanfosson, but I like mine for readability.

+1

Source: https://habr.com/ru/post/1731857/


All Articles