* 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
<input id="phone" type="text" pattern="dashes_only" required >