https://github.com/scriptex/html5-form-validator
The simplest HTML5 forms validator
https://github.com/scriptex/html5-form-validator
form-validation html5 html5-forms validation validator
Last synced: 10 months ago
JSON representation
The simplest HTML5 forms validator
- Host: GitHub
- URL: https://github.com/scriptex/html5-form-validator
- Owner: scriptex
- License: mit
- Created: 2017-11-26T12:42:41.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2025-03-10T05:11:31.000Z (11 months ago)
- Last Synced: 2025-03-18T04:42:43.067Z (10 months ago)
- Topics: form-validation, html5, html5-forms, validation, validator
- Language: TypeScript
- Homepage: https://html5-form-validator.atanas.info
- Size: 978 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.com/scriptex/html5-form-validator)
[](https://github.com/scriptex/html5-form-validator/actions?query=workflow%3ABuild)
[](https://www.codacy.com/gh/scriptex/html5-form-validator/dashboard?utm_source=github.com&utm_medium=referral&utm_content=scriptex/html5-form-validator&utm_campaign=Badge_Grade)
[](https://codebeat.co/projects/github-com-scriptex-html5-form-validator-master)
[](https://www.codefactor.io/repository/github/scriptex/html5-form-validator)
[](https://deepscan.io/dashboard#view=project&tid=3574&pid=5257&bid=40799)
[](https://github.com/scriptex/html5-form-validator/)
# HTML5 Form Validator
> The simplest HTML5 forms validator.
This form validator uses the **built-in capabilities** of the browser to validate the required form fields.
All validation messages are shown as they are shown by the browser which means that they are **internationalized** and are **NOT subject to change**.
## Visitor stats




## Code stats





## Install
```sh
npm i html5-form-validator
```
or
```sh
yarn add html5-form-validator
```
## Usage
```javascript
import { HTML5FormValidation } from 'html5-form-validator';
```
Then initialize with default settings:
```javascript
new HTML5FormValidation();
```
or supply your own
```javascript
const form = document.querySelector('#form');
new HTML5FormValidation(form, {
errorElement: 'form__error',
invalidClass: 'is--invalid',
submitHandler(instance) {
console.log(instance);
},
validateOnInput: false
});
```
## Options
| Option | Type | Required | Default | Description |
| ----------------- | ---------- | -------- | ----------- | --------------------------------------------------------------------------------------------------- |
| `errorElement` | `string` | false | `'error'` | The class name of the element that will be added to the DOM after the required field. |
| `invalidClass` | `string` | false | `'invalid'` | The classname of the required field when it is invalid |
| `submitHandler` | `Function` | false | `null` | A function to run on form submission. Accepts a single argument - the HTML5FormValidation instance. |
| `validateOnInput` | `boolean` | false | `true` | Validate as you type. Set to `false` to validate only on submit. |
## LICENSE
MIT
---
Connect with me:
---