@@ -164,7 +164,8 @@ const Validation = (() => {
164164 // ----- Validation Methods -----
165165 // ------------------------------
166166
167- const validEmail = value => / ^ ( ( [ a - z A - Z 0 - 9 ] [ ^ ! @ £ $ % ^ & * = / ? § ± ~ < > ( ) { } [ \] \\ . , ; : \s @ " ' ` ] + ( \. [ ^ ! @ £ $ % ^ & * = / ? § ± ~ < > ( ) { } [ \] \\ . , ; : \s @ " ' ` ] + ) * ) | ( " .+ " ) ) @ ( ( \[ [ 0 - 9 ] { 1 , 3 } \. [ 0 - 9 ] { 1 , 3 } \. [ 0 - 9 ] { 1 , 3 } \. [ 0 - 9 ] { 1 , 3 } \] ) | ( ( [ a - z A - Z 0 - 9 ] + \. ) + [ a - z A - Z ] { 2 , } ) ) $ / . test ( value ) ;
167+ const validEmail = value => / ^ [ a - z A - Z 0 - 9 ] + (?: (? ! .* ( [ . + _ - ] ) \1+ ) [ a - z A - Z 0 - 9 . + _ - ] + ) * [ a - z A - Z 0 - 9 ] @ (?: [ a - z A - Z 0 - 9 ] (?: [ a - z A - Z 0 - 9 - ] * [ a - z A - Z 0 - 9 ] ) ? \. ) + [ a - z A - Z ] (?: [ a - z A - Z - ] * [ a - z A - Z ] ) { 1 , } ?$ / . test ( value ) ;
168+
168169 const validRequired = ( value , options , field ) => {
169170 if ( value . length ) return true ;
170171 // else
@@ -318,8 +319,8 @@ const Validation = (() => {
318319 }
319320
320321 let all_is_ok = true ;
321- let message = '' ;
322322 const field_type = field . $ . attr ( 'type' ) ;
323+ let message_template = '' ;
323324
324325 field . validations . some ( ( valid ) => {
325326 if ( ! valid ) return false ; // check next validation
@@ -350,13 +351,13 @@ const Validation = (() => {
350351 }
351352
352353 if ( ! field . is_ok ) {
353- message = options . message || ValidatorsMap . get ( type ) . message ;
354+ message_template = options . message || ValidatorsMap . get ( type ) . message ;
354355 if ( type === 'length' ) {
355- message = template ( message , [ options . min === options . max ? options . min : `${ options . min } -${ options . max } ` ] ) ;
356+ message_template = template ( message_template , [ options . min === options . max ? options . min : `${ options . min } -${ options . max } ` ] ) ;
356357 } else if ( type === 'min' ) {
357- message = template ( message , [ options . min ] ) ;
358+ message_template = template ( message_template , [ options . min ] ) ;
358359 } else if ( type === 'not_equal' ) {
359- message = template ( message , [ options . name1 , options . name2 ] ) ;
360+ message_template = template ( message_template , [ options . name1 , options . name2 ] ) ;
360361 }
361362 all_is_ok = false ;
362363 return true ; // break on the first error found
@@ -365,7 +366,7 @@ const Validation = (() => {
365366 } ) ;
366367
367368 if ( ! all_is_ok ) {
368- showError ( field , message ) ;
369+ showError ( field , message_template ) ;
369370 } else {
370371 clearError ( field ) ;
371372 }
@@ -382,11 +383,10 @@ const Validation = (() => {
382383 }
383384 } ;
384385
385- const showError = ( field , localized_message ) => {
386- if ( field . $error . html ( ) === localized_message && field . $error . is ( ':visible' ) ) return ;
387- clearError ( field ) ;
386+ const showError = ( field , message ) => {
388387 Password . removeCheck ( field . selector ) ;
389- field . $error . html ( localized_message ) . setVisibility ( 1 ) ;
388+ field . $error . text ( message ) ;
389+ field . $error . setVisibility ( 1 ) ;
390390 } ;
391391
392392 const validate = ( form_selector ) => {
0 commit comments