Commit 34ab0d8edb1c81ae868a98656379d87b6fb90e3e

Authored by Fabio Teixeira
1 parent 67e55265

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 })();
... ...