html5-form-validator
Advanced tools
Comparing version 0.0.0 to 0.0.1
@@ -31,3 +31,3 @@ export default class html5formValidation { | ||
event.preventDefault(); | ||
this.settings.submitHandler(this); | ||
@@ -53,3 +53,3 @@ } | ||
field.nextSibling.textContent = field.validationMessage; | ||
} | ||
}; | ||
@@ -60,5 +60,4 @@ field.oninput = () => { | ||
field.checkValidity(); | ||
} | ||
}; | ||
} | ||
} | ||
} |
{ | ||
"name": "html5-form-validator", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "The most simple HTML5 form validator", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
@@ -13,11 +10,3 @@ "type": "git", | ||
}, | ||
"keywords": [ | ||
"HTML5", | ||
"form", | ||
"validator", | ||
"JS", | ||
"validator", | ||
"form", | ||
"validator" | ||
], | ||
"keywords": ["HTML5", "form", "validator"], | ||
"author": "Atanas Atanasov <scriptex.bg@gmail.com> (https://github.com/scriptex)", | ||
@@ -24,0 +13,0 @@ "license": "MIT", |
@@ -1,2 +0,52 @@ | ||
# html5-form-validator | ||
# HTML5 Form Validator | ||
The most simple HTML5 forms validator | ||
## Install | ||
``` | ||
npm i html5-form-validator | ||
``` | ||
or | ||
``` | ||
yarn add html5-form-validator | ||
``` | ||
## Usage | ||
``` | ||
import 'html5-form-validator'; | ||
``` | ||
Then initialize with default settings: | ||
``` | ||
new html5formValidation(); | ||
``` | ||
or supply your own | ||
``` | ||
const form = document.querySelector('#form'); | ||
new html5formValidation(form, { | ||
errorElement: 'form__error', | ||
invalidClass: 'is--invalid', | ||
submitHandler(instance) { | ||
console.log(instance) | ||
}, | ||
validateOnInput: false | ||
}); | ||
``` | ||
## Options | ||
`errorElement` - The classname of the element that will be added to the dom after the required field. Defaults to `error`. | ||
`invalidClass` - The classname of the required field when it is invalid. Defaults to `invalid`. | ||
`submitHandler` - A function to run on valid form submission. Accepts a single `instance` argument which refers to the constuctor's instance. Defaults to `null`. | ||
`validateOnInput` - Set to false if you want to show visual feedback for invalid fields after the first invalid submission. Defaults to `true`. |
Sorry, the diff of this file is not supported yet
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
6609
1
52
50