GithubHelp home page GithubHelp logo

proform's Introduction

incomplete, but making public to free up paid repo space

I intend to come back to this at some point.

proform

Philosophy

A JavaScript library for making web forms usable.

Primarily user-centric, also attempting to be developer-centric. Ability to extend and customise is very important.

Built around asynchronous flow- async calls seem to trip up many form libraries.

Desirables

  • Easy validation
  • Sensible config out of the box
  • Validation markup hinting
  • Fallback without JavaScript
  • Work in step with HTML5 validation
  • Flexible extension for validation
  • Asynchronous (promises)
  • Localisation
  • Multi-stage forms
  • Form flow / dependencies

Dependencies

  • jQuery

User-centric behaviour

  • Input is selected - show input hint
  • User enters their first attempt
  • System checks validity on each key press, so we can put a validation tick next to the input if acceptable. No errors are visibly raised yet.
  • When the input is finished ('change' event) then display if there's an error
  • System checks validity on each key press, so we can put a validation tick next to the input if acceptable, or errors.

Usage

  1. Create an HTML5 page and include, in the following order:

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type="text/javascript" src="~proform/lib/proform.js"></script> <script type="text/javascript" src="~proform/lib/proform-validators.js"></script> <script type="text/javascript" src="~proform/lib/proform-lang-en-gb.js"></script>
  2. Set validation requirements on your inputs

  3. Assign proform to the relevant forms in the document.ready

    <script> $( document ).ready( function() { $( 'form.proform' ).proform(); }); </script>
  4. Try, then customise!

Customisation

Validation Options

  • Mandatory - the user must enter something in this input if the section is unhidden

    data-pf-mandatory

  • Built in validators

    data-pf-validator="uk-postcode"

  • Regex match

    data-pf-pattern="/regex/i"

Language Selection

$.proform.option( 'language', 'fr-fr' );

Extension

Validators

Add, or override PROFORM.validators

// cb( null ) for no error
// cb( something ) for error
PROFORM.validators[ validator-id ] = function( value, cb ) {

	cb( ! /^[a-z]{2}[0-9]{1,2} ?[0-9]{1,2}[a-z]{2}$/i.test( value ) );
}

Languages

PROFORM.languages[ language-code ] = {		// language code should be like en-gb
	string_id: string
	...
}

proform's People

Contributors

creativenucleus avatar

Watchers

 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.