Coder Social home page Coder Social logo

mm4-you-js-form-validator's Introduction

MM4 You Javascript Form Validator

Version: 1.0

This javascript validator requires valid HTML markup, and assignment of two variables in the javascript file to function. It has no dependencies. Currently, it checks for empty values on fields that are marked as required, and "valid" email addresses on input[type="email"] using a regular expression (whether the email field is required or not).

This has been tested in IE10+, IE Edge, Chrome 53+, Firefox 48+, Mobile Safari 5.1+, Android 4.0

This demo is set up to validate one form on the page, but additional forms can be validated by adding the two required variables as well as an additional event listener at the end of the script for each form you want to add.

HTML Form Instructions:

Markup your form(s). Add a class of "required" to form elements (input, textarea, select, email, radio, etc.) that are required form fields in order to submit the form. Add the "data-error-label" attribute to create an error name. This is the name that will be displayed to the user when their submission fails validation. Add an html element with a class of "msg-box" in your form to display the form errors. In this demo, it is a "div".

Javascript Instructions:

You will need to enter two variables:

  1. "errorClass" - The CSS class that you are using to style errors in the DOM.
  2. "form" - The "name" attribute of the form that you would like to validate.

No further edits are necessary. After declaring your variables, you should minify "mm4-you-validate.js" and use that in your HTML markup. Commenting has been added throughout the unminified version of the script for explanation of functionality.

mm4-you-js-form-validator's People

Contributors

cstielper 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.