Commit 34ab0d8edb1c81ae868a98656379d87b6fb90e3e

Authored by Fabio Teixeira
1 parent 67e55265
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: Fix site url regex bug

Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Showing 1 changed file with 11 additions and 32 deletions   Show diff stats
public/mpog-user-validations.js
... ... @@ -176,7 +176,7 @@
176 176 var invalid = false;
177 177  
178 178 for(var i = 0; i < slices.length; i++) {
179   - if( slices[i].length > 3 ) {
  179 + if( slices[i].length > 3 || text.length <= 3 ) {
180 180 invalid = full_validation.test(slices[i]);
181 181 } else {
182 182 invalid = partial_validation.test(slices[i]);
... ... @@ -188,17 +188,6 @@
188 188 return invalid;
189 189 }
190 190  
191   - jQuery("#profile_data_name").blur(function(){
192   - jQuery(this).attr("class", "");
193   -
194   - if( this.value.length > 0 && is_invalid_formated(this.value) ) {
195   - show_full_name_error_message();
196   - } else {
197   - hide_full_name_error_message();
198   - }
199   - });
200   -
201   -
202 191 // Generic
203 192 function show_plugin_error_message(field_id, hidden_message_id ) {
204 193 var field = jQuery("#"+field_id);
... ... @@ -229,18 +218,16 @@
229 218 });
230 219 }
231 220  
232   - function invalid_email_validation(value)
233   - {
  221 + function invalid_email_validation(value) {
234 222 var correct_format_regex = new RegExp(/^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/);
235 223  
236   - return !correct_format_regex.test(value)
  224 + return !correct_format_regex.test(value);
237 225 }
238 226  
239   - function invalid_site_validation(value)
240   - {
241   - var correct_format_regex = new RegExp(/^http[s]{0,1}:\/\/[\w*\.]*/);
  227 + function invalid_site_validation(value) {
  228 + var correct_format_regex = new RegExp(/(^|)(http[s]{0,1})\:\/\/(\w+[.])\w+/g);
242 229  
243   - return !correct_format_regex.test(value)
  230 + return !correct_format_regex.test(value);
244 231 }
245 232  
246 233 //End generic
... ... @@ -278,18 +265,10 @@
278 265 fix_phone_mask_format("#profile_data_comercial_phone");
279 266 fix_phone_mask_format("#profile_data_contact_phone");
280 267  
281   - addBlurFields("profile_data_name", "full_name_error", is_invalid_formated)
282   - addBlurFields("profile_data_email", "email_error", invalid_email_validation)
283   - addBlurFields("user_secondary_email", "email_error", invalid_email_validation)
284   - addBlurFields("profile_data_personal_website", "site_error", invalid_site_validation)
285   - addBlurFields("profile_data_organization_website", "site_error", invalid_site_validation)
286   -
287   - window.setTimeout(function(){
288   - /*
289   - Noosfero application.js is one of the last loaded javascript files.
290   - Then, to override an application.js validation, this code waits for 2 seconds.
291   - Or else, application.js validation override this validation
292   - */
293   - }, 2000);
  268 + addBlurFields("profile_data_name", "full_name_error", is_invalid_formated);
  269 + addBlurFields("profile_data_email", "email_error", invalid_email_validation);
  270 + addBlurFields("user_secondary_email", "email_error", invalid_email_validation);
  271 + addBlurFields("profile_data_personal_website", "site_error", invalid_site_validation);
  272 + addBlurFields("profile_data_organization_website", "site_error", invalid_site_validation);
294 273 });
295 274 })();
... ...