jzaefferer/jquery-validation — pull request #1058 by lagden (2014-03-29 19:37:02+00:00)
Title: UMD (Universal Module Definition) patterns for JavaScript modules

Much better to use with Requirejs...

**Example:**

``` javascript
define(function(require) {

'use strict';

require('jquery');
require('jquery/validation/locatization/pt-br');
require('jquery/validation/delegate');
require('jquery/validation/core');

// Form
var $myTestForm = $('#myTestForm');

// Override
$.validator.addMethod('date', function(value, element) {
return this.optional(element) || (/^(0[1-9]|[12][0-9]|3[01])[- \/\.](0[1-9]|1[012])[- \/\.](\d{4})$/).test(value);
}, 'Data no formato inválido. Ex.: 01/09/1981');

// Validator
var validator = $myTestForm.validate({
focusInvalid: false,
submitHandler: function() {
console.log("submitted!");
},
showErrors: function(errorMap, errorList) {
var totalError = errorList.length;
if (totalError > 0) {
for (var i = 0; i < totalError; i++) {
var el = errorList[i].element;
var title = el.getAttribute('title') || el.getAttribute('data-title') || 'Aviso';
var msg = el.getAttribute('data-error-message') || errorList[i].message;
console.log(title, msg);
}
}
},
onfocusin: function() {},
onfocusout: function() {},
onkeyup: function() {},
onclick: function() {},
unhighlight: function() {},
highlight: function() {}
});
});
```