Last active
September 8, 2016 20:31
-
-
Save boonebgorges/4980c7706623fd5f9f4fc1915e541182 to your computer and use it in GitHub Desktop.
Better "equalto" implementation for Parsley.js
This file contains 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 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