useInputs with array
For multiple inputs, You can use as arguments :
- An array of string
- An array of a mix of string and object
- An array of object
When you use an array of string, the input is VALID by default, because there is no validation attached to it.
Please use it if :
- You want some inputs with no validation
Import
Import useInputs from aio-inputs package
Array of string
Call useInputs with an array of string. For example, you want the name, phoneNumber, and gender of a user
myInputs contains these related ready-to-use properties.
Now bind some input element.
That is it. The value entered by the user will be stored in correspondingip.valuelocated in myInputs.
Validity
To know if your form (all your inputs) is valid, use isValid property. Every input has also his own valid property
You can RESET or also get all VALUES by using the FORM OBJECT.
Now if you want to change the type of the input, the label or other properties and add some validations, you should use object. You can still use string and create a combination of none validated inputs and validated ones.
Array of string and object
Let's create three inputs. Age with validation (minimum 18) and type number, Name and Firstname with no validation.
We will use object for age input and string for others.
Now bind myInputs, to some input element. We will also display the error message if an input is touched and is not valid.
That is it. The value entered by the user will be stored in correspondingip.valuelocated in myInputs.
Validity
To know if your form (all your inputs) is valid, use isValid property. Every input has also his own valid property
You can RESET or also get all VALUES by using the FORM OBJECT.
INPUTS PROPERTIES like name, type and many others are available.
Same for VALIDATION PROPERTIES like min, max and many others.
Hit next to find out how to use object with aio-inputs