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

Specific input field's error message doesn't work #79

Open
Galimard opened this issue Jan 18, 2022 · 1 comment
Open

Specific input field's error message doesn't work #79

Galimard opened this issue Jan 18, 2022 · 1 comment
Labels

Comments

@Galimard
Copy link

There are two examples of custom error message in your documentation, but they are doesn't work:

  1. Example of a specific input field's error message:
    <input type="text" data-validate-length-range="2,6" required="required" pattern="alphanumeric" data-validate-text-invalid='Please follow the pattern rules'/>

  2. Another example:

<input type="text" name="mySpecialInput" data-validate-length-range="2,6" required="required" pattern="alphanumeric" />
var validator = new FormValidator({
    texts : {
        mySpecialInput: 'wrong input' // set custom error message for that specific field, by "name"
    }
});

On your demo page doesn't work too http://yaireo.github.io/validator/ https://skr.sh/sC41V6PuNAu

So I searched for data-validate-text-invalid in validator.js and didn't find it, this functionality is not implemented.

So I wrote it by myself. In the checkField function we get testResult from hasValue. Must be passed to hasValue an option data, not data.value
image
In the function hasValue we can check data.invalidtext and show it instead of the default error
image
Now I have custom errors via data-validate-text-invalid attribute.

@yairEO
Copy link
Owner

yairEO commented Jan 18, 2022

Thanks for reporting, I will investigate!

@yairEO yairEO added the bug label Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants