From fcc4cb92ed14312ef760445d7755bb30bdc4cf03 Mon Sep 17 00:00:00 2001 From: Avinash Agarwal Date: Sun, 28 Apr 2019 23:02:59 +0530 Subject: [PATCH] mod input dont accept same mod --- client/views/create/create.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/client/views/create/create.js b/client/views/create/create.js index b9cf1b50..24151174 100644 --- a/client/views/create/create.js +++ b/client/views/create/create.js @@ -102,6 +102,21 @@ Template.create.events({ }*/ const modsInput = document.getElementsByClassName('instancemodsinput'); const mods = []; + + for (let m = 0; m < modsInput.length; m++) { + if (modsInput[m].checkValidity()) { + for (let n = m + 1; n < modsInput.length; n++) { + if (modsInput[m].value === modsInput[n].value) { + showCreateError('Same moderator cannot be added more than once.'); + return false; + } + } + } else { + showCreateError(modsInput[m].value + ' is not a valid email.'); + return false; + } + } + for (let m = 0; m < modsInput.length; m++) { if (modsInput[m].checkValidity()) { if (modsInput[m].value) {