-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
112 lines (98 loc) · 3.14 KB
/
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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
function load(id){
window.open("./"+id+".html", "_self");
}
function validateEmail(email) {
var re = /\S+@\S+\.\S+/;
return re.test(email);
}
function sendMail(manufacturer, model, modelYear, additionalMessage,fName,lName,phoneNumber,eMail) {
var link = "mailto:[email protected]"
+ "?subject=" + encodeURIComponent("Custom order of: "+modelYear+" "+manufacturer+" "+model)
+ "&body=Name: "+fName +" "+lName+" Phone number and mail: "+phoneNumber+" "+eMail+" Additional message: " + encodeURIComponent(additionalMessage);
window.location.href = link;
}
function submit()
{
var fName=document.getElementById("firstName");
var lName=document.getElementById("lastName");
var eMail=document.getElementById("eMail");
var phoneNumber=document.getElementById("phoneNumber");
var manufacturer=document.getElementById("manufacturer");
var model=document.getElementById("model");
var modelYear=document.getElementById("modelYear");
var additionalMessage=document.getElementById("additionalMessage");
if(validateEmail(eMail.value)==false)
{
window.alert("E-Mail is not in valid form!");
eMail.value='';
}
else if(manufacturer.value=="" || model.value=="" || modelYear.value=="")
{
window.alert("Manufacturer, model and model year are required!");
}
else{
sendMail(manufacturer.value, model.value, modelYear.value, additionalMessage.value, fName.value ,lName.value ,phoneNumber.value ,eMail.value);
fName.value='';
lName.value='';
eMail.value='';
phoneNumber.value='';
manufacturer.value='';
model.value='';
modelYear.value='';
additionalMessage.value='';
}
}
function selectCar(carid)
{
var carinfo = document.getElementById("carInfo");
var model = document.getElementById(carid+"model").innerHTML;
var firstName=document.getElementById("firstName");
carinfo.value=model;
firstName.scrollIntoView();
}
function closepopup() {
var blur = document.getElementById("blur");
var body = document.getElementById("body");
blur.classList.add("hidden");
body.classList.remove("stop-scrolling");
}
function appoint()
{
var firstName=document.getElementById("firstName");
var lastName=document.getElementById("lastName");
var eMail=document.getElementById("eMail");
var phoneNumber=document.getElementById("phoneNumber");
var carinfo = document.getElementById("carInfo");
var date = document.getElementById("date");
var blur = document.getElementById("blur");
var body = document.getElementById("body");
if (carinfo.value=="")
{
window.alert("You must select a car!");
}
else if(firstName.value=="" || lastName.value=="" || eMail.value=="" || phoneNumber=="")
{
window.alert("Personal info is required!");
}
else if(validateEmail(eMail.value)==false)
{
window.alert("E-Mail is not in valid form!");
eMail.value='';
}
else if(date.value=="")
{
window.alert("Pick a date!");
}
else
{
firstName.value='';
lastName.value='';
eMail.value='';
phoneNumber.value='';
carinfo.value='';
date.value='';
blur.classList.remove("hidden");
body.classList.add("stop-scrolling");
window.scrollTo(0, 0);
}
}