Skip to content

Commit

Permalink
Preventing double submission of same value
Browse files Browse the repository at this point in the history
  • Loading branch information
codepo8 committed Jul 1, 2022
1 parent 50167b6 commit 4d17e1e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions demo-to-do/to-do.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ const addTask = e => {
if (task.value) {
let t = task.value.replace(/[^A-Z|0-9| ]+/ig, '');
if (t.value !== t) {
console.warn('cleaned up task value');
console.warn('Cleaned up task value');
t.value = t;
}
console.info('Adding Task :' + t);
tasks[t] = 'active';
updateList();
task.value = '';
if (!tasks[t]) {
console.info('Adding Task :' + t);
tasks[t] = 'active';
updateList();
task.value = '';
} else {
console.warn('Task already exists');
}
}
e.preventDefault();
};
Expand Down

0 comments on commit 4d17e1e

Please sign in to comment.