Commit 0be3b09ccdf9584924d7660ee36d22ec3da3ac6f
1 parent
8dae35ef
Exists in
master
and in
5 other branches
correcoes_aderencia: Refatore full name javascript verifivation
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Showing
1 changed file
with
22 additions
and
14 deletions
Show diff stats
public/mpog-user-validations.js
| @@ -96,23 +96,31 @@ | @@ -96,23 +96,31 @@ | ||
| 96 | return reg_firsts_char.test(text) || reg_special_char.test(text); | 96 | return reg_firsts_char.test(text) || reg_special_char.test(text); |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | + function show_full_name_error_message() { | ||
| 100 | + var field = jQuery("#profile_data_name"); | ||
| 101 | + | ||
| 102 | + field.removeClass("validated").addClass("invalid"); | ||
| 103 | + | ||
| 104 | + if(!jQuery(".full_name_error")[0]) { | ||
| 105 | + var message = jQuery("#full_name_error").val(); | ||
| 106 | + field.parent().append("<span class='full_name_error'>"+message+"</span>"); | ||
| 107 | + } else { | ||
| 108 | + jQuery(".full_name_error").show(); | ||
| 109 | + } | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + function hide_full_name_error_message() { | ||
| 113 | + jQuery("#profile_data_name").removeClass("invalid").addClass("validated"); | ||
| 114 | + jQuery(".full_name_error").hide(); | ||
| 115 | + } | ||
| 116 | + | ||
| 99 | jQuery("#profile_data_name").blur(function(){ | 117 | jQuery("#profile_data_name").blur(function(){ |
| 100 | jQuery(this).attr("class", ""); | 118 | jQuery(this).attr("class", ""); |
| 101 | 119 | ||
| 102 | - if( this.value.length > 0 ) { | ||
| 103 | - if( is_invalid_formated(this.value) ) { | ||
| 104 | - jQuery(this).removeClass("validated").addClass("invalid"); | ||
| 105 | - | ||
| 106 | - if(!jQuery(".full_name_error")[0]) { | ||
| 107 | - var message = jQuery("#full_name_error").val(); | ||
| 108 | - jQuery(this).parent().append("<span class='full_name_error'>"+message+"</span>"); | ||
| 109 | - } else { | ||
| 110 | - jQuery(".full_name_error").show(); | ||
| 111 | - } | ||
| 112 | - } else { | ||
| 113 | - jQuery(this).removeClass("invalid").addClass("validated"); | ||
| 114 | - jQuery(".full_name_error").hide(); | ||
| 115 | - } | 120 | + if( this.value.length > 0 && is_invalid_formated(this.value) ) { |
| 121 | + show_full_name_error_message(); | ||
| 122 | + } else { | ||
| 123 | + hide_full_name_error_message(); | ||
| 116 | } | 124 | } |
| 117 | }); | 125 | }); |
| 118 | } | 126 | } |