Skip to content

Commit

Permalink
Update to select the correct formFieldName
Browse files Browse the repository at this point in the history
The original implementation doesn't allow you to pass in the name of the field to compare to in the same attribute.
  • Loading branch information
shanezr authored Sep 13, 2016
1 parent 56fabea commit 650da4a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions js/scrupulous.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@
function that checks if a value is equal to another value
based on the id value contained in data-equal-to attribue.
----------------------------------------------*/
var equalTo = function(el){
var equalToParentId = $(el).attr('data-equal-to');
var equalTo = function(el,parent){
var equalToParentId;
if ( typeof parent !== 'undefined'){
equalToParentId = parent;
}
else {
equalToParentId = $(el).attr('data-equal-to');
}
if($('#' + equalToParentId).length >= 0) {
// Compare to another input's value
if (el.value != $('#' + equalToParentId).val()) {
Expand Down Expand Up @@ -259,7 +265,7 @@
}

if($(el).attr('data-not-equal-to-with-base') !== undefined){
elValidity = elValidity && !equalTo(el);
elValidity = elValidity && !equalTo(el,$(el).attr('data-not-equal-to-with-base'));
}

if($el.is(':checkbox') || $el.is(':radio')){
Expand Down

0 comments on commit 650da4a

Please sign in to comment.