jQuery-Validation-Engine icon indicating copy to clipboard operation
jQuery-Validation-Engine copied to clipboard

Can't show error message

Open LeQuangKhai99 opened this issue 2 years ago • 1 comments

I have a validate: $("div[name='birthday-form']").addClass("validate[required], custom[checkbirth], custom[checkbirthyear], custom[checkbirthmonth], custom[checkbirthday]"); But I don't want to display the 'required' error anymore, so I changed the validation to $("div[name='birthday-form']").addClass("validate[custom[checkbirth], custom[checkbirthyear], custom[checkbirthmonth], custom[checkbirthday]]"); but now it doesn't show the error message. Do you know why?

LeQuangKhai99 avatar Dec 12 '23 08:12 LeQuangKhai99

I have the same problem, so I used another approach: funcCallRequired.

validate[funcCallRequired[checkbirthyear]]

For the function, when it's correct, it needs to return undefined. I'm not sure if this is the best way to do it, but it works for me.

function checkbirthyear() {
    const birthyear = $("#" + "birthyear").val();
    let msg = isValidYear(birthyear);
    if (msg) {
        return msg;
    } else {
    // This is needed to prevent the error message from showing when it's correct.
        return undefined;
    }
}

yvelltt avatar Dec 16 '24 06:12 yvelltt