Add contributor's email validation

This commit is contained in:
Benjamin Renard 2014-01-30 23:44:25 +01:00
parent bb84db00c0
commit 47542c397f

View file

@ -249,6 +249,11 @@ on_show_add_contributor_modal=function(e) {
$('#add_contributor_modal #add_contributor_name').focus();
}
validateEmail=function(email) {
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,}))$/;
return re.test(email);
}
on_valid_add_contributor_modal=function(e) {
e.preventDefault();
var group=groups[$('#add_contributor_modal').data('group-uuid')];
@ -268,6 +273,10 @@ on_valid_add_contributor_modal=function(e) {
alert('Un contributor utilise déjà cet email !');
return;
}
if (!validateEmail(email)) {
alert('Email invalide !');
return;
}
if(edit_id=='-1') {
group.addContributor(new Contributor(name,email));
}