-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
46 lines (40 loc) · 1.48 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
//function validate()
var contactForm = document.getElementById('contact-form');
contactForm.onsubmit = function() {
//event.preventDefault();
console.log('success');
let name = document.getElementById("Name").value;
let email = document.getElementById("Email").value;
let feedback = document.getElementById("Feedback").value;
//regex to perform email validation
var ereg=/^\w+([.-]?\w+)@\w+([.-]?\w+)(.\w{2,3})+$/g;
//check the name is not null
document.getElementById("Name").required = true;
if (name == "" ) {
window.alert("Please enter your Name.");
document.getElementById("Name").focus();
return false;
}
document.getElementById("Email").required = true;
//check the email is valid or not null
if (email == "" || !ereg.test(email)) {
window.alert("Please enter a valid e-mail address.");
document.getElementById("Email").focus();
return false;
}
document.getElementById("Feedback").required = true;
if (feedback=="") {
document.getElementById("Feedback").focus();
return false;
}
//when all the validation was success then return true
return true;
}
// side menu
var sidemenu = document.getElementById("sidemenu");
function openmenu(){
sidemenu.style.right = "0";
}
function closemenu(){
sidemenu.style.right = "-200px";
}