Browse Source

#2214 Adds different[] validation, match not working correctly

pull/2228/merge
jlukic 9 years ago
parent
commit
b9af864341
1 changed files with 28 additions and 6 deletions
  1. 34
      src/definitions/behaviors/form.js

34
src/definitions/behaviors/form.js

@ -1128,6 +1128,28 @@ $.fn.form.settings = {
;
},
// matches another field
different: function(value, fieldIdentifier) {
// use either id or name of field
var
$form = $(this),
matchingValue
;
if( $('[data-validate="'+ fieldIdentifier +'"]').length > 0 ) {
matchingValue = $('[data-validate="'+ fieldIdentifier +'"]').val();
}
else if($('#' + fieldIdentifier).length > 0) {
matchingValue = $('#' + fieldIdentifier).val();
}
else if($('[name="' + fieldIdentifier +'"]').length > 0) {
matchingValue = $('[name="' + fieldIdentifier + '"]').val();
}
return (matchingValue !== undefined)
? ( value.toString() !== matchingValue.toString() )
: false
;
},
// matches another field
match: function(value, fieldIdentifier) {
// use either id or name of field
@ -1135,14 +1157,14 @@ $.fn.form.settings = {
$form = $(this),
matchingValue
;
if( $form.find('[data-validate="'+ fieldIdentifier +'"]').length > 0 ) {
matchingValue = $form.find('[data-validate="'+ fieldIdentifier +'"]').val();
if( $('[data-validate="'+ fieldIdentifier +'"]').length > 0 ) {
matchingValue = $('[data-validate="'+ fieldIdentifier +'"]').val();
}
else if($form.find('#' + fieldIdentifier).length > 0) {
matchingValue = $form.find('#' + fieldIdentifier).val();
else if($('#' + fieldIdentifier).length > 0) {
matchingValue = $('#' + fieldIdentifier).val();
}
else if($form.find('[name="' + fieldIdentifier +'"]').length > 0) {
matchingValue = $form.find('[name="' + fieldIdentifier + '"]').val();
else if($('[name="' + fieldIdentifier +'"]').length > 0) {
matchingValue = $('[name="' + fieldIdentifier + '"]').val();
}
return (matchingValue !== undefined)
? ( value.toString() == matchingValue.toString() )

Loading…
Cancel
Save