Class: Input

vivalid. Input

new Input(el, validatorsNameOptionsTuples, onInputValidationResultopt, isBlurOnly)

creates a new Input object wrapping around a DOM object.
Parameters:
Name Type Attributes Description
el HTMLElement the DOM object to wrap. For radios and checkboxes, pass only 1 element- the class will find it's siblings with the same name attribute.
validatorsNameOptionsTuples Array.<_internal.validatorsNameOptionsTuple> the order matters- the input's state is the first validatorsNameOptionsTuple that evulates to a non-valid (pending or invalid) state.
onInputValidationResult function <optional>
Signature of onInputValidationResult. A function to handle an input state or message change. If not passed, defaultOnInputValidationResult will be used.
isBlurOnly boolean if true, doesn't not trigger validation on 'input' or 'change' events.
Source:
Example
new Input(document.getElementById('Name'), [['required',{msg: 'custom required message'}],['max',{max: 10}]])