1.0.0 • Published 9 years ago
check-passwords v1.0.0
Check Passwords
Tool for check passwords in form fields using webpack and pure javascript in the client.
Installation
Via npm npm install check-passwords
Usage and API documentation
This tool is make for will used with webpack as a module.
The class CheckPasswords
It's the main class and receive as paramater an object of configuration, this object can have the following properties and method.
target{DOMObject}, This should be the form DOM object and is optional, if is undefined then the form DOM object will be the first form element that exists atbody.passwordFields{Array}, This should be the array of inputs fields type password and is optional, if is undefined then the inputs will be the first two inform.onMatch{Function}, This function is called when the password in the two fields are equals.onDontMatch{Function}, This function is called when the password in the two fields aren't equals.
The method watch is for listen the event blur in the second field when this change it, after that the functions onMatch and onDontMatch are called if the passwords equals or not.
Example
const CheckPasswords = require('check-passwords');
window.onload = function () {
const MyCheckPass = new CheckPasswords({
target: document.getElementById('form'),
passwordFields: [
document.querySelector('.password'),
document.querySelector('.repear-password')
],
onMatch: function () {
// When the passwords are equals.
},
onDontMatch: function () {
// When don't.
}
});
// Call method watch for listen blur event in the second field.
MyCheckPass.watch();
};Test
You need have installed globaly webpack and execute npm run test for test the tool in your browser.
License
1.0.0
9 years ago