Created
February 17, 2015 21:13
-
-
Save dshook/3f125d3d9fae7df728c4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| WEBLINC.formValidation = (function () { | |
| 'use strict'; | |
| var setup = function () { | |
| var CREDIT_CARD_NUMBER_WHITE_LIST = ['1', '2', '3'], | |
| setDefaults = function () { | |
| $.validator.setDefaults({ | |
| meta: 'validation', | |
| ignoreTitle: true, | |
| errorClass: 'error' | |
| }); | |
| }, | |
| customize = function () { | |
| $.validator.addMethod('extendedCreditCard', function (value, element) { | |
| if (_.contains(CREDIT_CARD_NUMBER_WHITE_LIST, value)) { | |
| return true; | |
| } else { | |
| return $.validator.methods.creditcard.call(this, value, element); | |
| } | |
| }, $.validator.messages.creditcard); | |
| }; | |
| setDefaults(); | |
| customize(); | |
| }, | |
| init = function ($scope) { | |
| $('form', $scope).each(function () { | |
| $(this).validate(); | |
| }); | |
| }; | |
| WEBLINC.modules.onDomReady(setup, init); | |
| WEBLINC.modules.onDomUpdate(init); | |
| return { | |
| init: init | |
| }; | |
| }()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment