Commit fd355e41e5e8b3b950b0fc8c778b92607b6e8a49

Authored by Fabio Teixeira
1 parent de00280f
Exists in master and in 79 other branches add_sisp_to_chef, add_super_archives_plugin, api_for_colab, automates_core_packing, backup_not_prod, changes_in_buttons_on_content_panel, colab_automated_login, colab_spb_plugin_recipe, colab_widgets_settings, design_validation, dev_env_minimal, disable_email_dev, fix_breadcrumbs_position, fix_categories_software_link, fix_edit_institution, fix_edit_software_with_another_license, fix_get_license_info, fix_gitlab_assets_permission, fix_list_style_inside_article, fix_list_style_on_folder_elements, fix_members_pagination, fix_merge_request_url, fix_models_translations, fix_no_license, fix_software_api, fix_software_block_migration, fix_software_communities_translations, fix_software_communities_unit_test, fix_style_create_institution_admin_panel, fix_superarchives_imports, fix_sym_links_noosfero, focus_search_field_theme, gov-user-refactoring, gov-user-refactoring-rails4, header_fix, institution_modal_on_rating, kalibro-conf-refactoring, kalibro-processor-package, lxc_settings, margin_fix, mezuro_cookbook, prezento, refactor_download_block, refactor_software_communities, refactor_software_for_sisp, register_page, release-process, release-process-v2, remove-unused-images, remove_broken_theme, remove_secondary_email_from_user, remove_sisp_buttons, removing_super_archives_email, review_message, scope2method, signals_user_noosfero, sisp_catalog_header, sisp_colab_config, sisp_dev, sisp_dev_master, sisp_simple_version, software_as_organization, software_catalog_style_fix, software_communities_html_refactor, software_infos_api, spb_minimal_env, spb_to_rails4, spec_refactor, stable-4.1, stable-4.2, stable-4.x, temp_soft_comm_refactoring, theme_header, theme_javascript_refactory, thread_dropdown, thread_page, update_search_by_categories, update_software_api, update_softwares_boxes

correcoes_aderencia: Fields mark in red or green depending on the validation

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
public/mpog-user-validations.js
... ... @@ -186,7 +186,11 @@
186 186 });
187 187 }
188 188  
189   - function is_invalid_formated(text) {
  189 + function invalid_name_validation(text) {
  190 + if( text.trim().length == 0 ) {
  191 + return true;
  192 + }
  193 +
190 194 var full_validation = /([^\w\*\s*])|(^|\s)([a-z]|[0-9])/; // no special chars and do not initialize with no capital latter
191 195 var partial_validation = /[^\w\*\s*]/; // no special chars
192 196 text = replace_some_special_chars(text);
... ... @@ -207,8 +211,8 @@
207 211 }
208 212  
209 213 // Generic
210   - function show_plugin_error_message(field_id, hidden_message_id ) {
211   - var field = jQuery("#"+field_id);
  214 + function show_plugin_error_message(field_selector, hidden_message_id ) {
  215 + var field = jQuery(field_selector);
212 216  
213 217 field.removeClass("validated").addClass("invalid");
214 218  
... ... @@ -220,23 +224,28 @@
220 224 }
221 225 }
222 226  
223   - function hide_plugin_error_message(field_id, hidden_message_id) {
224   - jQuery("#" + field_id).removeClass("invalid").addClass("validated");
  227 + function hide_plugin_error_message(field_selector, hidden_message_id) {
  228 + jQuery(field_selector).removeClass("invalid").addClass("validated");
225 229 jQuery("." + hidden_message_id).hide();
226 230 }
227   - function addBlurFields(field_id, hidden_message_id, validation_function) {
228   - jQuery("#" + field_id).blur(function(){
  231 +
  232 + function addBlurFields(field_selector, hidden_message_id, validation_function) {
  233 + jQuery(field_selector).blur(function(){
229 234 jQuery(this).attr("class", "");
230 235  
231   - if( this.value.length > 0 && validation_function(this.value) ) {
232   - show_plugin_error_message(field_id, hidden_message_id);
  236 + if( validation_function(this.value) ) {
  237 + show_plugin_error_message(field_selector, hidden_message_id);
233 238 } else {
234   - hide_plugin_error_message(field_id, hidden_message_id);
  239 + hide_plugin_error_message(field_selector, hidden_message_id);
235 240 }
236 241 });
237 242 }
238 243  
239 244 function invalid_email_validation(value) {
  245 + if( value.trim().length == 0 ) {
  246 + return true;
  247 + }
  248 +
240 249 var correct_format_regex = new RegExp(/^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/);
241 250  
242 251 return !correct_format_regex.test(value);
... ... @@ -285,10 +294,10 @@
285 294 fix_phone_mask_format("#profile_data_comercial_phone");
286 295 fix_phone_mask_format("#profile_data_contact_phone");
287 296  
288   - addBlurFields("profile_data_name", "full_name_error", is_invalid_formated);
289   - addBlurFields("profile_data_email", "email_error", invalid_email_validation);
290   - addBlurFields("user_secondary_email", "email_error", invalid_email_validation);
291   - addBlurFields("profile_data_personal_website", "site_error", invalid_site_validation);
292   - addBlurFields("profile_data_organization_website", "site_error", invalid_site_validation);
  297 + addBlurFields("#profile_data_name", "full_name_error", invalid_name_validation);
  298 + addBlurFields("#profile_data_email", "email_error", invalid_email_validation);
  299 + addBlurFields("#user_secondary_email", "email_error", invalid_email_validation);
  300 + addBlurFields("#profile_data_personal_website", "site_error", invalid_site_validation);
  301 + addBlurFields("#profile_data_organization_website", "site_error", invalid_site_validation);
293 302 });
294 303 })();
... ...
public/style.css
... ... @@ -118,3 +118,12 @@
118 118 border: solid 1px #000;
119 119 }
120 120  
  121 +#profile-data .invalid {
  122 + border-color: rgb(127, 0, 0);
  123 + box-shadow: 0px 0px 7px red;
  124 +}
  125 +
  126 +#profile-data .validated {
  127 + box-shadow: 0px 0px 7px green;
  128 + border-color: rgb(0, 80, 0)
  129 +}
121 130 \ No newline at end of file
... ...