From 22cd6c3e3d440ce60e81a570b9111c8b04455f5e Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Fri, 23 Jan 2015 18:27:55 +0100 Subject: [PATCH] Add validation for email notifications before submit --- public/js/vroom.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/public/js/vroom.js b/public/js/vroom.js index 5329ba7..7db4634 100644 --- a/public/js/vroom.js +++ b/public/js/vroom.js @@ -174,6 +174,7 @@ function addEmailInputField(val){ currentEntry = parentEl.find('.email-entry:last'), newEntry = $(currentEntry.clone()).appendTo(parentEl); newEntry.find('input').val(val); + newEntry.removeClass('has-error'); adjustAddRemoveEmailButtons(); } // Adjust add and remove buttons foir email notifications @@ -252,6 +253,22 @@ $('#configureRoomForm').submit(function(e){ return false; } } + var validEmail = true; + $('.email-list').find('input').each(function(index, input){ + if (!$(input).val().match(/\S+@\S+\.\S+/)){ + $(input).parent().addClass('has-error'); + //$(input).parent().notify(locale.ERROR_MAIL_INVALID, 'error'); + validEmail = false; + // Break the each loop + return false; + } + else{ + $(input).parent().removeClass('has-error'); + } + }); + if (!validEmail){ + return false; + } var locked = $('#lockedSet').bootstrapSwitch('state'), askForName = $('#askForNameSet').bootstrapSwitch('state'), joinPass = ($('#joinPassSet').bootstrapSwitch('state')) ?