Commit 3e0761f4eeba1e8634d5caf13a72611af0109af7
1 parent
aa66130d
Exists in
master
and in
79 other branches
correcoes_aderencia: Allow blank field on secondary email
Signed-off-by: Fabio Teixeira <fabio1079@gmail.com>
Showing
1 changed file
with
6 additions
and
6 deletions
Show diff stats
public/mpog-user-validations.js
... | ... | @@ -229,11 +229,11 @@ |
229 | 229 | jQuery("." + hidden_message_id).hide(); |
230 | 230 | } |
231 | 231 | |
232 | - function addBlurFields(field_selector, hidden_message_id, validation_function) { | |
232 | + function addBlurFields(field_selector, hidden_message_id, validation_function, allow_blank) { | |
233 | 233 | jQuery(field_selector).blur(function(){ |
234 | 234 | jQuery(this).attr("class", ""); |
235 | 235 | |
236 | - if( validation_function(this.value) ) { | |
236 | + if( validation_function(this.value, !!allow_blank) ) { | |
237 | 237 | show_plugin_error_message(field_selector, hidden_message_id); |
238 | 238 | } else { |
239 | 239 | hide_plugin_error_message(field_selector, hidden_message_id); |
... | ... | @@ -241,9 +241,9 @@ |
241 | 241 | }); |
242 | 242 | } |
243 | 243 | |
244 | - function invalid_email_validation(value) { | |
245 | - if( value.trim().length == 0 ) { | |
246 | - return true; | |
244 | + function invalid_email_validation(value, allow_blank) { | |
245 | + if( allow_blank && value.trim().length == 0 ) { | |
246 | + return false; | |
247 | 247 | } |
248 | 248 | |
249 | 249 | var correct_format_regex = new RegExp(/^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/); |
... | ... | @@ -296,7 +296,7 @@ |
296 | 296 | |
297 | 297 | addBlurFields("#profile_data_name", "full_name_error", invalid_name_validation); |
298 | 298 | addBlurFields("#profile_data_email", "email_error", invalid_email_validation); |
299 | - addBlurFields("#user_secondary_email", "email_error", invalid_email_validation); | |
299 | + addBlurFields("#user_secondary_email", "email_error", invalid_email_validation, true); | |
300 | 300 | addBlurFields("#profile_data_personal_website", "site_error", invalid_site_validation); |
301 | 301 | addBlurFields("#profile_data_organization_website", "site_error", invalid_site_validation); |
302 | 302 | }); | ... | ... |