-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
36 lines (26 loc) · 989 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
let submitButton = document.querySelector('#submit-button');
function clickListener(event) {
event.preventDefault();
let emailInput = document.querySelector('#email');
let messageInput = document.querySelector('#message');
let emailText = emailInput.value;
let messageText = messageInput.value;
console.log('email: ', emailText, 'message: ', messageText);
function emailValidate(email){
return email.includes('@');
}
if(emailValidate(emailText) !== true){
console.log('Email address must contain @');
return false;
}
console.log('Thanks for your message!');
function validateNSFW(message){
return message.includes('crap');
}
if(validateNSFW(messageText) !== true){
console.log('This message is safe for work.');
} else {
console.log('This message is not safe for work.');
}
}
submitButton.addEventListener('click', clickListener);