crazy-form
v1.0.0
Published
Crazy-form for form and objects validation. Error handler etc...
Downloads
1
Readme
What is this?
Crazy-form for form and objects validation. Error handler etc...
Installation
npm i crazy-form --save
Then...
const email = document.getElementById('email');
const password = document.getElementById('password');
crazyForm.init(
{
email: {
label: 'Email',
validation: {
isEmail: true,
isRequired: true,
type: 'string',
element: email
},
error: {
ref: document.getElementById('email-error'),
addClass: 'red',
message: 'Popuni email',
appendMessage: true
}
},
password: {
label: 'Password',
validation: {
isPassword: true,
isRequired: true,
type: 'string',
element: password
},
error: {
ref: document.getElementById('password-error'),
addClass: 'red popup',
message: 'Popuni password'
}
}
},
{}
)
Then...
btn.onclick = () => {
const valid = crazyForm.validateAll(false);
if(!valid) {
const some = crazyForm.getAllErrors();
}
}
Or...
btn.onclick = () => {
const valid = crazyForm.validateAll(false);
const single = crazyForm.isValid('password');
}