Answer the question
In order to leave comments, you need to log in
How to force validate form data in Yii2?
There is a drop-down step-by-step filling in the form, at the end there is a submit data button. You need to do this: when you press the button, first validate the data (which happens by itself), then, if an error is detected, open the desired tab. The problem is that if you immediately catch the button click event, then there will be no errors at the time of checking, js code:
$('.send-btn').click(function(e) {
$('#step-content-1').find('.help-block-error').each(function() {
if(needStep == 0) {
if($(this).text() != '') {
needStep = 1;
}
}
});
$('#step-content-2').find('.help-block-error').each(function() {
if(needStep == 0) {
if($(this).text() != '') {
needStep = 2;
}
}
});
if(needStep > 0) {
closeAll();
toggleStep(needStep);
}
});
$("#myForm").data("yiiActiveForm").submitting = true;
$("#myForm").yiiActiveForm("validate");
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question