File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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} ;
You can’t perform that action at this time.
0 commit comments