/Another-JS-Form-Validator

Primary LanguageJavaScriptApache License 2.0Apache-2.0

Another-JS-Form-Validator

Plain Javascript for validating forms based on html:5 form validation

Usage

Single form element

const formElement = document.querySelector('.form');
const inputElements = formElement.querySelectorAll('input, select, textarea, button');
new FormValidation(formElement, inputElements);

Multiple form elements

const formElements = document.querySelectorAll('.form');
for (let i = 0; i < formElements.length; i++) {
	const inputElements = formElements[i].querySelectorAll('input, select, textarea, button');
	new FormValidation(formElements[i], inputElements);
}