horprogs / Just-validate

Modern, simple, lightweight (~5kb gzip) form validation library written in Typescript, with no dependencies (no JQuery!). Support a wide range of predefined rules, async, files, dates validation, custom error messages and styles, localization. Support writing custom rules and plugins.

Home Page:https://just-validate.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Repeat Password doesn't work

cgahmann opened this issue · comments

On the Example page the "Repeat your password" field does not work. https://just-validate.dev/examples/
The problem is that fields['#example2_password'] doesn't exist. It exists only fields['2'] etc:

.addField('#example2_repeat-password', [
    {
        rule: 'required',
    },
    {
        validator: (value, fields) => {
            if (
                fields['#example2_password'] &&
                fields['#example2_password'].elem
            ) {
                const repeatPasswordValue =
                    fields['#example2_password'].elem.value;

                return value === repeatPasswordValue;
            }

            return true;
        },
        errorMessage: 'Passwords should be the same',
    },
])

And there's a typo error at "Quick start" under "Also it is possible to use a DOM element as a field in the .addField() method." There is one "]);" too much at the end: https://just-validate.dev/documentation/#section-2

Thanks for the catch, fixed! Also adjusted the docs.