Skip to content

Commit f86984c

Browse files
author
shankarThiyagaraajan
committed
- Centralized error holder ID for ES5 & ES6.
1 parent a0b91dd commit f86984c

3 files changed

Lines changed: 28 additions & 25 deletions

File tree

src/demo/index3.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
<button type="submit" name="btn-save" class="btn btn-default">Submit</button>
8989
</form>
9090
</div>
91-
<script src="./../js/multi_formValidator.es6.js"></script>
91+
<script src="./../js/multi_formValidator.js"></script>
9292

9393
<script>
9494

src/js/multi_formValidator.es6.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
* For Managing overall Validation flow.
2525
*/
2626
let firstErrorHit = false;
27+
let __err_id_suffix_rand_hash = '_new1_1_1xv_resp';
28+
2729
/**
2830
* Core Js Validator.
2931
*/
@@ -575,9 +577,9 @@ class jsRuleSets {
575577
log.push({
576578
'el': activeElem,
577579
'type': 'required',
578-
'id': activeElem.name + '_new1_1_1xv_resp'
580+
'id': activeElem.name + __err_id_suffix_rand_hash
579581
});
580-
firstErrorHit = activeElem.name + '_new1_1_1xv_resp';
582+
firstErrorHit = activeElem.name + __err_id_suffix_rand_hash;
581583
}
582584

583585
// To Check the Value is less than minimum or not.
@@ -587,9 +589,9 @@ class jsRuleSets {
587589
log.push({
588590
'el': activeElem,
589591
'type': 'min',
590-
'id': activeElem.name + '_new1_1_1xv_resp'
592+
'id': activeElem.name + __err_id_suffix_rand_hash
591593
});
592-
firstErrorHit = activeElem.name + '_new1_1_1xv_resp';
594+
firstErrorHit = activeElem.name + __err_id_suffix_rand_hash;
593595
validElem = false;
594596
}
595597
}
@@ -602,9 +604,9 @@ class jsRuleSets {
602604
log.push({
603605
'el': activeElem,
604606
'type': 'max',
605-
'id': activeElem.name + '_new1_1_1xv_resp'
607+
'id': activeElem.name + __err_id_suffix_rand_hash
606608
});
607-
firstErrorHit = activeElem.name + '_new1_1_1xv_resp';
609+
firstErrorHit = activeElem.name + __err_id_suffix_rand_hash;
608610
validElem = false;
609611
}
610612
}
@@ -617,9 +619,9 @@ class jsRuleSets {
617619
log.push({
618620
'el': activeElem,
619621
'type': 'email',
620-
'id': activeElem.name + '_new1_1_1xv_resp'
622+
'id': activeElem.name + __err_id_suffix_rand_hash
621623
});
622-
firstErrorHit = activeElem.name + '_new1_1_1xv_resp';
624+
firstErrorHit = activeElem.name + __err_id_suffix_rand_hash;
623625
validElem = false;
624626
}
625627
}
@@ -633,9 +635,9 @@ class jsRuleSets {
633635
log.push({
634636
'el': activeElem,
635637
'type': 'password',
636-
'id': activeElem.name + '_new1_1_1xv_resp'
638+
'id': activeElem.name + __err_id_suffix_rand_hash
637639
});
638-
firstErrorHit = activeElem.name + '_new1_1_1xv_resp';
640+
firstErrorHit = activeElem.name + __err_id_suffix_rand_hash;
639641
validElem = false;
640642
}
641643
}
@@ -644,7 +646,7 @@ class jsRuleSets {
644646
if (true === validElem) {
645647
//jsLogger.out('Valid Elem', activeElem);
646648
if (activeElem.name !== '') {
647-
let elem = document.getElementById(activeElem.name + '_new1_1_1xv_resp');
649+
let elem = document.getElementById(activeElem.name + __err_id_suffix_rand_hash);
648650
if (typeof (elem) !== 'undefined' && elem !== null) {
649651
// Remove element to avoid un-necessary buffer.
650652
elem.remove();
@@ -895,7 +897,7 @@ let helper = {
895897
// Forming ID.
896898
let id = document.getElementsByClassName(active_class)[0].id;
897899
// Retrieve the element name.
898-
let elem_name = active_id.replace('_new1_1_1xv_resp', '');
900+
let elem_name = active_id.replace(__err_id_suffix_rand_hash, '');
899901
// Taking active element to navigate.
900902
let top = document.getElementsByName(elem_name)[0].offsetTop;
901903
// Format as ID.

src/js/multi_formValidator.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* For Managing overall Validation flow.
2525
*/
2626
var firstErrorHit = false;
27+
var __err_id_suffix_rand_hash = '_new1_1_1xv_resp';
2728
/**
2829
* Core Js Validator.
2930
*/
@@ -541,9 +542,9 @@ function jsRuleSets() {
541542
log.push({
542543
'el': activeElem,
543544
'type': 'required',
544-
'id': activeElem.name + '_new1_1_1xv_resp'
545+
'id': activeElem.name + __err_id_suffix_rand_hash
545546
});
546-
firstErrorHit = activeElem.name + '_new1_1_1xv_resp';
547+
firstErrorHit = activeElem.name + __err_id_suffix_rand_hash;
547548
}
548549

549550
// To Check the Value is less than minimum or not.
@@ -553,9 +554,9 @@ function jsRuleSets() {
553554
log.push({
554555
'el': activeElem,
555556
'type': 'min',
556-
'id': activeElem.name + '_new1_1_1xv_resp'
557+
'id': activeElem.name + __err_id_suffix_rand_hash
557558
});
558-
firstErrorHit = activeElem.name + '_new1_1_1xv_resp';
559+
firstErrorHit = activeElem.name + __err_id_suffix_rand_hash;
559560
validElem = false;
560561
}
561562
}
@@ -568,9 +569,9 @@ function jsRuleSets() {
568569
log.push({
569570
'el': activeElem,
570571
'type': 'max',
571-
'id': activeElem.name + '_new1_1_1xv_resp'
572+
'id': activeElem.name + __err_id_suffix_rand_hash
572573
});
573-
firstErrorHit = activeElem.name + '_new1_1_1xv_resp';
574+
firstErrorHit = activeElem.name + __err_id_suffix_rand_hash;
574575
validElem = false;
575576
}
576577
}
@@ -583,9 +584,9 @@ function jsRuleSets() {
583584
log.push({
584585
'el': activeElem,
585586
'type': 'email',
586-
'id': activeElem.name + '_new1_1_1xv_resp'
587+
'id': activeElem.name + __err_id_suffix_rand_hash
587588
});
588-
firstErrorHit = activeElem.name + '_new1_1_1xv_resp';
589+
firstErrorHit = activeElem.name + __err_id_suffix_rand_hash;
589590
validElem = false;
590591
}
591592
}
@@ -599,9 +600,9 @@ function jsRuleSets() {
599600
log.push({
600601
'el': activeElem,
601602
'type': 'password',
602-
'id': activeElem.name + '_new1_1_1xv_resp'
603+
'id': activeElem.name + __err_id_suffix_rand_hash
603604
});
604-
firstErrorHit = activeElem.name + '_new1_1_1xv_resp';
605+
firstErrorHit = activeElem.name + __err_id_suffix_rand_hash;
605606
validElem = false;
606607
}
607608
}
@@ -610,7 +611,7 @@ function jsRuleSets() {
610611
if (true === validElem) {
611612
//jsLogger.out('Valid Elem', activeElem);
612613
if (activeElem.name !== '') {
613-
var elem = document.getElementById(activeElem.name + '_new1_1_1xv_resp');
614+
var elem = document.getElementById(activeElem.name + __err_id_suffix_rand_hash);
614615
if (typeof (elem) !== 'undefined' && elem !== null) {
615616
// Remove element to avoid un-necessary buffer.
616617
elem.remove();
@@ -849,7 +850,7 @@ var helper = {
849850
// Forming ID.
850851
var id = document.getElementsByClassName(active_class)[0].id;
851852
// Retrieve the element name.
852-
var elem_name = active_id.replace('_new1_1_1xv_resp', '');
853+
var elem_name = active_id.replace(__err_id_suffix_rand_hash, '');
853854
// Taking active element to navigate.
854855
var top = document.getElementsByName(elem_name)[0].offsetTop;
855856
// Format as ID.

0 commit comments

Comments
 (0)