Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't show error message #989

Open
LeQuangKhai99 opened this issue Dec 12, 2023 · 1 comment
Open

Can't show error message #989

LeQuangKhai99 opened this issue Dec 12, 2023 · 1 comment

Comments

@LeQuangKhai99
Copy link

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?

@yvelltt
Copy link

yvelltt commented Dec 16, 2024

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;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants