Skip to content

Commit 5c09c3c

Browse files
committed
feat: standardizes the scope message
Limits the maximum number of characters and informs if the quantity is ideal
1 parent fba290e commit 5c09c3c

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

assets/script/index.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,47 @@ type.querySelector('form').onsubmit = function(e) { e.preventDefault();
7171

7272
}
7373

74+
};
75+
76+
77+
scope.querySelector('form').scope.onfocus = function() {
78+
79+
let typeSize = type.querySelector('form').type.value.length;
80+
let ornamentSize = (' ()!: ').length;
81+
82+
let maxLength = 50 - typeSize - ornamentSize;
83+
84+
this.maxLength = maxLength;
85+
86+
scope.querySelector('form > div > label > small').innerHTML = this.value.length +' / '+ this.maxLength;
87+
88+
};
89+
scope.querySelector('form').scope.oninput = function() {
90+
91+
let small = scope.querySelector('form > div > label > small');
92+
93+
if (this.value.length == 0) {
94+
95+
small.className = '';
96+
small.title = '';
97+
98+
} else if (this.value.length < (+this.maxLength / 3)) {
99+
100+
small.className = 'good';
101+
small.title = 'Good';
102+
103+
} else if (this.value.length < (+this.maxLength / 3) * 2) {
104+
105+
small.className = 'caution';
106+
small.title = 'Extensive';
107+
108+
} else {
109+
110+
small.className = 'danger';
111+
small.title = 'Enormous';
112+
113+
}
114+
115+
small.innerHTML = this.value.length +' / '+ this.maxLength;
116+
74117
};

0 commit comments

Comments
 (0)