Skip to content

Instantly share code, notes, and snippets.

@boonebgorges
Last active September 8, 2016 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boonebgorges/4980c7706623fd5f9f4fc1915e541182 to your computer and use it in GitHub Desktop.
Save boonebgorges/4980c7706623fd5f9f4fc1915e541182 to your computer and use it in GitHub Desktop.
Better "equalto" implementation for Parsley.js
var iffRecursion = false;
window.Parsley.addValidator( 'iff', {
validateString: function( value, requirement, instance ) {
var $partner = $( requirement );
var isValid = $partner.val() == value;
if ( iffRecursion ) {
iffRecursion = false;
} else {
iffRecursion = true;
$partner.parsley().validate();
}
return isValid;
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment