simple-javascript-validator v1.0.24
Simple Javascript Validator
This package aims to validate the input data in javascript using the most common validation rules.
This was made with the intention to be used by those who are just practicing using npm packages to their projects (students, beginners, hobbyist, etc.).
Installation
npm install simple-javascript-validator
Validation Rules
Validation | Rule |
---|---|
required | Value must be required |
number | Value must be a number |
Value must be an email | |
gtzero | Select tag must have a value |
gtzero - Because select tag's initial value is zero as shown in the example below:
<select>
<option value="0" selected="selected">- select -</option>
<option value="1">Admin</option>
<option value="2">Guest</option>
</select>
How To Use
Please run the index.html
file
<script src="simple-javascript-validator.min.js"></script>
var full_name = document.getElementById("name").value;
var age = document.getElementById("age").value;
var email_address = document.getElementById("email_address").value;
var role = document.getElementById("role").value;
var validateData = {
name : full_name + '|required',
age : age + '|required,number',
email : email_address + '|required,email',
role : role + '|gtzero'
};
var errors = validateInputs(validateData);
if(errors){
console.log(errors);
//toastr['error'](errors);
return false;
}
License
The MIT License
Support
You can ask for support by emailing k a p i t a n n w e l a t g m a i l d o t c o m
Donate
Use this for free, donation is optional.
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago