validateAllInput
The validateAllInput function validates all input fields within a specified form and returns an array of error messages (a nested ErrorMessageInterface) if invalid, or a single instance of ErrorMessageInterface if all fields are valid.
Works in: HTML5, React JS
| Parameter | Type | Default | Description |
|---|---|---|---|
form | HTMLFormElement | HTMLDivElement | string | undefined | The form element or its ID. |
options | object | {} | Additional options for validation. |
Usage
Example: Validate All Input Fields in a Form
const formElement = document.getElementById('myForm');
nfsfu234FormValidation.validateAllInput(formElement, {
customErrorMessages: {
email: 'Please enter a valid email address.',
url: 'Please enter a valid URL.',
date: 'Please enter a valid date.',
}
}).then(response => {
console.log(response);
});See also
Last updated on