From 3bfb07b075e760f61f7937d8dd1f04fb29cc6b0e Mon Sep 17 00:00:00 2001 From: Nicolas Coden Date: Sat, 10 Mar 2018 22:01:39 +0100 Subject: [PATCH] docs: add infos in the Abide custom validator example --- docs/pages/abide.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/pages/abide.md b/docs/pages/abide.md index 92442c0d0..d150beb67 100644 --- a/docs/pages/abide.md +++ b/docs/pages/abide.md @@ -345,22 +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'] = - -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)); }; -// Init Foundation -$(document).foundation(); +// Set default options +Foundation.Abide.defaults.patterns['dashes_only'] = /^[0-9-]*$/; +Foundation.Abide.defaults.validators['greater_than'] = myCustomValidator; +// Initialize Foundation +$(document).foundation(); ``` ```html -- 2.47.2