1.0.24 • Published 4 years ago

simple-javascript-validator v1.0.24

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

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

ValidationRule
requiredValue must be required
numberValue must be a number
emailValue must be an email
gtzeroSelect 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.

1.0.24

4 years ago

1.0.23

4 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.11

4 years ago

1.0.12

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago