-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrehme.js
78 lines (61 loc) · 2.27 KB
/
rehme.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
function validateForm(event) {
event.preventDefault();
const animalType = document.getElementById('input_select').value;
const breed = document.getElementById('input-breed').value;
const size = document.getElementById('input-size').value;
const marking = document.getElementById('input-marking').value;
const features = document.getElementById('input-features').value;
const location = document.getElementById('input-location').value;
const address = document.getElementById('input-address').value;
const fullName = document.getElementById('input-name').value;
const email = document.getElementById('input-email').value;
const phoneNumber = document.getElementById('input-number').value;
const image = document.getElementById('customFile').value;
const emailRegex = /^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/;
if (animalType === '') {
alert('Please select the type of animal.');
return;
}
if (breed === '') {
alert('Please enter the breed of the animal.');
return;
}
if (isNaN(size) || size <= 0) {
alert('Please enter a valid size/approximate weight.');
return;
}
if (marking === '') {
alert('Please enter the color/markings of the animal.');
return;
}
if (features === '') {
alert('Please provide distinctive features and characteristics of the animal.');
return;
}
if (location === '') {
alert('Please enter the location where the animal was spotted.');
return;
}
if (address === '') {
alert('Please enter specific location details.');
return;
}
if (fullName === '') {
alert('Please enter your full name.');
return;
}
if (!emailRegex.test(email)) {
alert('Please enter a valid email address.');
return;
}
if (isNaN(phoneNumber) || phoneNumber.length !== 10) {
alert('Please enter a valid 10-digit phone number.');
return;
}
if (image === '') {
alert('Please upload an image of the pet.');
return;
}
document.getElementById('myForm').submit();
}
document.getElementById('myForm').addEventListener('submit', validateForm);