Created
October 23, 2013 19:36
-
-
Save munro/7125210 to your computer and use it in GitHub Desktop.
Foundation abide compare field, for confirm password, verify password
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var parse_patterns = Foundation.libs.abide.parse_patterns; | |
Foundation.libs.abide.parse_patterns = function (els) { | |
var form = $(els[0]).closest('form'), | |
errors = parse_patterns.apply(this, arguments); | |
form.find('[field-match]').each(function () { | |
var $field = $(this), | |
$compare = form.find('[name="' + form.find('[field-match]').attr('field-match') + '"]'); | |
if ($field.val() === $compare.val()) { | |
$field.removeAttr('data-invalid').parent().removeClass('error'); | |
errors.push(true); | |
} else { | |
$field.attr('data-invalid', '').parent().addClass('error'); | |
errors.push(false); | |
} | |
}); | |
return errors; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment