File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -132,4 +132,34 @@ scope.querySelector('form').onreset = function() {
132132 behavior : 'smooth'
133133 } ) ;
134134
135+ } ;
136+
137+
138+ summary . querySelector ( 'form' ) . summary . onblur = function ( ) { // Standardize the message
139+
140+ this . value = this . value . trim ( ) ;
141+
142+ this . value =
143+ this . value . slice ( 0 , 1 ) . toLocaleLowerCase ( ) // Don't capitalize the first letter
144+ +
145+ this . value . slice ( 1 ) . split ( '.' ) . filter ( e => e ) . join ( '.' ) ; // No dot (.) at the end
146+
147+ } ;
148+ summary . querySelector ( 'form' ) . summary . onfocus = function ( ) {
149+
150+ let typeSize = type . querySelector ( 'form' ) . type . value . length ;
151+ let scopeSize = scope . querySelector ( 'form' ) . scope . value . trim ( ) . length ;
152+ let ornamentSize = ( scopeSize ? ' ()!: ' : '!: ' ) . length ;
153+
154+ let maxLength = 50 - typeSize - scopeSize - ornamentSize ;
155+
156+ this . maxLength = maxLength ;
157+
158+ summary . querySelector ( 'form > div > label > small' ) . innerHTML = this . value . length + ' / ' + this . maxLength + '<sub>50 - ' + ( 50 - this . maxLength ) + '</sub>' ;
159+
160+ } ;
161+ summary . querySelector ( 'form' ) . summary . oninput = function ( ) {
162+
163+ summary . querySelector ( 'form > div > label > small' ) . innerHTML = this . value . length + ' / ' + this . maxLength + '<sub>50 - ' + ( 50 - this . maxLength ) + '</sub>' ;
164+
135165} ;
You can’t perform that action at this time.
0 commit comments