GithubHelp home page GithubHelp logo

dexter4life / js-form-validator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from via-profit/js-form-validator

0.0 1.0 0.0 5.92 MB

Javascript form validation. Pure JS. No jQuery

Home Page: https://via-profit.github.io/js-form-validator

JavaScript 86.42% CSS 8.74% HTML 4.84%

js-form-validator's Introduction

Javascript form validator

Demo and Examples

We present you a very simple solution for validating HTML forms. If you do not want to pull a MB of JS dependencies, like, «jQuery» just for the sake of checking the correctness of the entered user data, then our solution will suit you.

Javascript Form Validator Screenshot Preview

How to use

  1. Include script on your page
  2. Apply «[data-rule]» attribute for each form element that you want to check, or the attribute value, specify the name of one or more rules
  3. You need to create an instance of Validator and pass it two parameters (Form handle and Callback function)
	<!-- Your form -->
	<form name="form" id="my-form">

		<!-- Required field email -->
		<input type="text" name="email" data-rule="required|email"/>

		<input type="submit" value="Submit"/>

	</form>

	<!-- Append the validator JS script -->
	<script type="text/javascript" src="js-form-validator.js"></script>

	<script>
		// Init validator with standart settings
		new Validator(document.querySelector('#my-form'), function (err, res) {
			return res;
		});
	</script>

What else

  • Rules customization
  • Errors messages customization
  • Automatic update when changing the form
  • Api

Full documentation and examples

js-form-validator's People

Contributors

vasily-novosad avatar kolyaraketa avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.