Giter Site home page Giter Site logo

shall-not-pass's Introduction

Shall Not Pass - Form Validation jQuery Plugin (another)

I created this plugin for personal use, but i think is time to get feedbacks and improve it.

I started using a jQuery Boilerplate and improve it adding method support. The code have a lot of comments, i hope it make easy to understand what are happening.

This project have a tests folder with Jasmine. I manage to write all tests to make easy new releases.

It is a really easy to use jquery plugin. Check it out the tips bellow.

  • All validation are based in input classes. If your input have a class who starts with "snp-", it will be validated. Ex.: snp-notnull, snp-password, ...

  • When a validation dont pass, the parent container of the input in question gain a class ".snp-error". Take it in mind.

  • When a validation dont pass, page scroll to begin of form and take focus on first input with an error.

  • To run the plugin:

$('form').shallNotPass();
  • You can pass a 'onValidationsPass' parameter. That will be called when all validations pass. Good to make a AJAX call.
$('form').shallNotPass({
    onValidationsPass: function(){
        console.info('onValidationsPass triggered');
    }
});

If you dont pass this parameter, form will follow the action as expected.

  • You can add your custons validations.
$('form').shallNotPass({
    validations: {
        'snp-foo': function(field){
            if(field.val() !== 'foos'){
                return {
                    pass: false,
                    errorMsg: 'This value must be "foos".'
                };
            };
            return true;
        }
    }
});

Check it out the live demo: http://fernandoperigolo.github.io/shall-not-pass/

shall-not-pass's People

Stargazers

Vinícius Almeida da Silva 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.