Add contributor's email validation
Benjamin Renard

Benjamin Renard commited on 2014-01-30 22:44:25
Showing 1 changed files, with 9 additions and 0 deletions.

... ...
@@ -249,6 +249,11 @@ on_show_add_contributor_modal=function(e) {
249 249
   $('#add_contributor_modal #add_contributor_name').focus();
250 250
 }
251 251
 
252
+validateEmail=function(email) {
253
+    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
254
+    return re.test(email);
255
+}
256
+
252 257
 on_valid_add_contributor_modal=function(e) {
253 258
   e.preventDefault();
254 259
   var group=groups[$('#add_contributor_modal').data('group-uuid')];
... ...
@@ -268,6 +273,10 @@ on_valid_add_contributor_modal=function(e) {
268 273
     alert('Un contributor utilise déjà cet email !');
269 274
     return;
270 275
   }
276
+  if (!validateEmail(email)) {
277
+    alert('Email invalide !');
278
+    return;
279
+  }
271 280
   if(edit_id=='-1') {
272 281
     group.addContributor(new Contributor(name,email));
273 282
   }
274 283