From: Brian Tan Date: Wed, 30 Dec 2015 23:57:47 +0000 (-0500) Subject: Update abide.md X-Git-Tag: v6.1.2~119^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=968f85d43ba418e73d25b27e767ada79613db054;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Update abide.md Add custom pattern and validator examples --- diff --git a/docs/pages/abide.md b/docs/pages/abide.md index b283dc1a3..47afef07a 100644 --- a/docs/pages/abide.md +++ b/docs/pages/abide.md @@ -178,3 +178,19 @@ $(document) return false; }); ``` +## Adding Custom Pattern and Validator +```javascript +$(document).foundation(); +Foundation.Abide.defaults.patterns['dashes_only'] = /^[0-9-]*$/; +Foundation.Abide.defaults.validators['greater_than'] = +function($el,required,parent) { + var from = $('#'+$el.attr('data-greater-than')).val(), + to = $el.val(); + return (parseInt(to) > parseInt(from)); +}; +``` +```html + + + +```