-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
60 lines (46 loc) · 1.47 KB
/
Copy pathscript.js
File metadata and controls
60 lines (46 loc) · 1.47 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
$(document).ready(function() {
$(window).scroll(function(){
if ($(window).scrollTop() >= 900) {
$('#back2Top').fadeIn();
} else {
$('#back2Top').fadeOut();
}
});
});
function validate(){
let name = document.getElementById("name").value,
subject = document.getElementById("subject").value,
phone = document.getElementById("phone").value,
email = document.getElementById("email").value,
message = document.getElementById("message").value,
error_message = document.getElementById("error_message"),
text;
error_message.style.padding = "10px";
if (name.length < 5) {
text = "Please enter a valid name";
error_message.innerHTML = text;
return false;
}
if (subject.length < 10) {
text = "Please enter a correct Subject";
error_message.innerHTML = text;
return false;
}
if (isNaN(phone) || phone.length != 10) {
text = "Please enter a valid Phone Number";
error_message.innerHTML = text;
return false;
}
if (email.indexOf("@") === -1 || email.length < 6) {
text = "Please enter a valid Email";
error_message.innerHTML = text;
return false;
}
if (message.length <= 140) {
text = "Please Enter more than 140 characters";
error_message.innerHTML = text;
return false;
}
alert("Form Submitted Successfully!");
return true;
}