diff --git a/docs/pages/abide.md b/docs/pages/abide.md index 2c4bf8e9c9..d150beb675 100644 --- a/docs/pages/abide.md +++ b/docs/pages/abide.md @@ -345,21 +345,23 @@ website: { * Add new patterns and validators before or after foundation is initialized ```javascript - -// Set paramaters -Foundation.Abide.defaults.patterns['dashes_only'] = /^[0-9-]*$/; -Foundation.Abide.defaults.validators['greater_than'] = - -// Init Foundation -$(document).foundation(); - -function($el,required,parent) { - // parameter 1 is jQuery selector +function myCustomValidator( + $el, /* jQuery element to validate */ + required, /* is the element required according to the `[required]` attribute */ + parent /* parent of the jQuery element `$el` */ +) { if (!required) return true; var from = $('#'+$el.attr('data-greater-than')).val(), to = $el.val(); return (parseInt(to) > parseInt(from)); }; + +// Set default options +Foundation.Abide.defaults.patterns['dashes_only'] = /^[0-9-]*$/; +Foundation.Abide.defaults.validators['greater_than'] = myCustomValidator; + +// Initialize Foundation +$(document).foundation(); ``` ```html