Peggy Pay kennisbasnk - Overig

Aangepaste invoervalidatie

Geschreven door: Ruben
Datum: Maandag 03 juli 2023

It is very easy to add your own custom validator. Lets say we only want to allow the text "test" in our input. Add the following code to your page to accomplish this.

let field = PeggyPay.getField("field");
field.addInputValidator(
    function(_field) {
        return _field.getValue() === "test";
    },
    "This value must be 'test'"
);