-
Notifications
You must be signed in to change notification settings - Fork 0
/
contact.js
86 lines (76 loc) · 2.05 KB
/
contact.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//drop down menu
var close = document.querySelector("#close")
var open = document.querySelector("#open")
var navv = document.querySelector("#navv")
function openn(e) {
navv.style.display = "flex"
open.style.display = "none"
close.style.display = "inline"
}
function closee() {
navv.style.display = "none"
open.style.display = "inline"
close.style.display = "none"
}
var user = document.getElementById("user");
var email = document.getElementById("email");
var subject = document.getElementById("subject");
var message = document.getElementById("message");
var alert_it = document.getElementById("alert-it");
var alert_name = document.getElementById("alert-name");
var alert_email = document.getElementById("alert-email");
var alert_subject = document.getElementById("alert-subject");
var alert_message = document.getElementById("alert-message");
function show_alert() {
alert_it.style.display = "block";
}
function hide_alert() {
alert_it.style.display = "none";
}
function V_name(user) {
var name_reg = /^[a-z ,.'-]+$/i;
if (name_reg.test(user.value)) {
return true;
}
else {
return false;
}
}
function V_email(email){
var email_reg=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
if (email_reg.test(email.value)) {
return true;
}
else {
console.log("not valid email");
return false;
}
}
function V_subject(subject) {
if (subject.value.length==0) {
return false;
}
else {
return true;
}
}
function V_message(message) {
if (message.value.length==0) {
return false;
}
else {
return true;
}
}
function submit_it() {
if(V_name(user) && V_email(email) && V_subject(subject) && V_message(message)){
alert_name.innerHTML=user.value;
alert_email.innerHTML=email.value;
alert_subject.innerHTML=subject.value;
alert_message.innerHTML=message.value;
show_alert();
}
else{
console.log("sth is wrong");
}
}