Skip to content

Commit 03c395f

Browse files
- Element navigation scroll | Under Testing.
1 parent 364fb55 commit 03c395f

1 file changed

Lines changed: 17 additions & 11 deletions

File tree

src/js/formValidator.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,10 @@ var jsRuleSets = {
535535
'id': activeElem.name + '_new1_1_1xv_resp'
536536
});
537537
firstErrorHit = activeElem.name + '_new1_1_1xv_resp';
538-
helper.scrollToItem('#' + firstErrorHit);
539-
} // To Check the Value is less than min or not.
538+
helper.scrollToItem(firstErrorHit);
539+
}
540540

541+
// To Check the Value is less than minimum or not.
541542
if (activeElem.min) {
542543
if (jsRuleSets.isSet(activeElem)) {
543544
if (!jsRuleSets.min(activeElem)) {
@@ -547,12 +548,13 @@ var jsRuleSets = {
547548
'id': activeElem.name + '_new1_1_1xv_resp'
548549
});
549550
firstErrorHit = activeElem.name + '_new1_1_1xv_resp';
550-
helper.scrollToItem('#' + firstErrorHit);
551+
helper.scrollToItem(firstErrorHit);
551552
validElem = false;
552553
}
553554
}
554-
} // To Check the Value is grater than max or not.
555+
}
555556

557+
// To Check the Value is grater than max or not.
556558
if (activeElem.max) {
557559
if (jsRuleSets.isSet(activeElem)) {
558560
if (!jsRuleSets.max(activeElem)) {
@@ -562,12 +564,13 @@ var jsRuleSets = {
562564
'id': activeElem.name + '_new1_1_1xv_resp'
563565
});
564566
firstErrorHit = activeElem.name + '_new1_1_1xv_resp';
565-
helper.scrollToItem('#' + firstErrorHit);
567+
helper.scrollToItem(firstErrorHit);
566568
validElem = false;
567569
}
568570
}
569-
} // To Check the Entered E-mail is Valid or Not.
571+
}
570572

573+
// To Check the Entered E-mail is Valid or Not.
571574
if (activeElem.type == 'email') {
572575
if (jsRuleSets.isSet(activeElem)) {
573576
if (!jsRuleSets.email(activeElem)) {
@@ -577,13 +580,14 @@ var jsRuleSets = {
577580
'id': activeElem.name + '_new1_1_1xv_resp'
578581
});
579582
firstErrorHit = activeElem.name + '_new1_1_1xv_resp';
580-
helper.scrollToItem('#' + firstErrorHit);
583+
helper.scrollToItem(firstErrorHit);
581584
validElem = false;
582585
}
583586
}
584-
} // To Compare the Password is Same or Not with Re-Password.
585-
// TODO: Implement Simplified Comparison.
587+
}
586588

589+
// To Compare the Password is Same or Not with Re-Password.
590+
// TODO: Implement Simplified Comparison.
587591
if (activeElem.type == 'password') {
588592
if (jsRuleSets.isSet(activeElem)) {
589593
if (!jsRuleSets.compare(activeElem)) {
@@ -593,7 +597,7 @@ var jsRuleSets = {
593597
'id': activeElem.name + '_new1_1_1xv_resp'
594598
});
595599
firstErrorHit = activeElem.name + '_new1_1_1xv_resp';
596-
helper.scrollToItem('#' + firstErrorHit);
600+
helper.scrollToItem(firstErrorHit);
597601
validElem = false;
598602
}
599603
}
@@ -817,7 +821,9 @@ var helper = {
817821
*/
818822
scrollToItem: function (item) {
819823
// Form hash value.
820-
var hash = '#' + item;
824+
var hash = item;
825+
// If "#" is missing, then add back to the ID.
826+
if (-1 === hash.indexOf('#')) hash = '#' + hash;
821827
// Navigate with the hash value.
822828
window.location.href = hash;
823829
// Remove the navigated value.

0 commit comments

Comments
 (0)