Skip to content

Commit 5cb66bd

Browse files
Merge pull request #41 from global-source/dev
- Updates on Compare element.
2 parents 2c58d28 + 6cda8c0 commit 5cb66bd

File tree

4 files changed

+50
-7
lines changed

4 files changed

+50
-7
lines changed

src/js/formValidator.es6.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,16 +810,38 @@ class jsRuleSets {
810810
let status = false;
811811
// If field is not required, then return "true".
812812
if (false === elem1.required) status = true;
813+
// 2'nd element's ID.
813814
let elem2_id = elem1.getAttribute('data-check');
815+
// Default 2'nd element comparision.
816+
let elem2_value = '';
817+
// Secondary element.
818+
let elem2 = false;
819+
// Verify, 2'nd element is defined or not.
814820
if (typeof elem2_id == 'undefined' || elem2_id == null) status = false;
821+
// If null, then take it's a primary element.
815822
if (elem2_id === null) elem2_id = elem1.getAttribute('data-parent');
823+
// If secondary element not defined, then "status" will FALSE.
816824
if (elem2_id === null) {
817825
status = false;
818826
} else {
827+
// If set, then take secondary element's id.
819828
elem2_id = elem2_id.toString();
820-
let elem2 = document.getElementById(elem2_id);
829+
// Get value of secondary element.
830+
elem2 = document.getElementById(elem2_id);
831+
// If both values are same, then "status" will TRUE.
821832
if (elem1.value === elem2.value) status = true;
833+
// Value of secondary element.
834+
elem2_value = elem2.value;
822835
}
836+
837+
// Throw error message for password validation.
838+
if (true === status || '' === elem2_value) {
839+
// Hardly remove the error message.
840+
document.getElementById(elem1.name + __err_id_suffix_rand_hash).remove();
841+
// Verify and remove error message.
842+
if (false !== elem2) document.getElementById(elem2.name + __err_id_suffix_rand_hash).remove();
843+
}
844+
823845
//jsLogger.out('Compare Status', status);
824846
return status;
825847
};

src/js/formValidator.es6.min.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/formValidator.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -768,20 +768,39 @@ function jsRuleSets() {
768768
var status = false;
769769
// If field is not required, then return "true".
770770
if (false === elem1.required) status = true;
771+
// 2'nd element's ID.
771772
var elem2_id = elem1.getAttribute('data-check');
773+
// Default 2'nd element comparision.
774+
var elem2_value = '';
775+
// Secondary element.
776+
var elem2 = false;
777+
// Verify, 2'nd element is defined or not.
772778
if (typeof elem2_id == 'undefined' || elem2_id == null) status = false;
779+
// If null, then take it's a primary element.
773780
if (elem2_id === null) elem2_id = elem1.getAttribute('data-parent');
781+
// If secondary element not defined, then "status" will FALSE.
774782
if (elem2_id === null) {
775783
status = false;
776784
} else {
785+
// If set, then take secondary element's id.
777786
elem2_id = elem2_id.toString();
778-
var elem2 = document.getElementById(elem2_id);
787+
// Get value of secondary element.
788+
elem2 = document.getElementById(elem2_id);
789+
// If both values are same, then "status" will TRUE.
779790
if (elem1.value === elem2.value) status = true;
791+
// Value of secondary element.
792+
elem2_value = elem2.value;
780793
}
781-
// Hardly remove the error message.
782-
// document.getElementById(elem1.name + __err_id_suffix_rand_hash).remove();
783-
// document.getElementById(elem2.name + __err_id_suffix_rand_hash).remove();
784794

795+
// Throw error message for password validation.
796+
if (true === status || '' === elem2_value) {
797+
// Hardly remove the error message.
798+
document.getElementById(elem1.name + __err_id_suffix_rand_hash).remove();
799+
// Verify and remove error message.
800+
if (false !== elem2) document.getElementById(elem2.name + __err_id_suffix_rand_hash).remove();
801+
}
802+
803+
//jsLogger.out('Compare Status', status);
785804
return status;
786805
};
787806
}

src/js/formValidator.min.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)