-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (30 loc) · 1.2 KB
/
index.js
File metadata and controls
41 lines (30 loc) · 1.2 KB
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
37
38
39
40
41
function send()
{
var from = document.getElementById("from").value;
var password = document.getElementById("password").value;
var to = document.getElementById("to").value;
var subject = document.getElementById("subject").value;
var message = document.getElementById("Message").value;
var valid=/^[a-zA-Z0-9.!#$%&'+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
if (subject.length===0||message.length===0||!from.match(valid)||!to.match(valid))
{
alert("Invalid Input")
}
else {
var xhttp = new XMLHttpRequest();
xhttp.open("POST", "https://email9876.herokuapp.com/data", true);
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
}
};
var json = {
"from": from,
"password": password,
"to": to,
"subject":subject,
"message":message
};
xhttp.send(JSON.stringify(json));
}
setTimeout(function () { window.location.reload(); }, 200);
}