-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_T.js
76 lines (62 loc) · 2.23 KB
/
main_T.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
function searchTable() {
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("myInput");
filter = input.value.toUpperCase();
table = document.getElementById("mySection");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[1];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
function validateForm() {
var adminId = document.getElementsByName("admin_Id_T")[0].value;
var packageType = document.querySelector('input[name="Package_Type_T"]:checked').value;
var roomClass = document.querySelector('select[name="Room_Class_Id_T"]').value;
if (!validateAdminId(adminId)) {
alert("Invalid Admin ID. Admin ID must be 5 characters long and start with a capital letter.");
return false;
}
if (packageType === 'LUXURY' && !roomClass.startsWith('D')) {
alert("You can only select room classes starting with 'Deluxe' for Luxury packages.");
return false;
}
if (packageType === 'Family' && !roomClass.startsWith('S')) {
alert("You can only select room classes starting with 'Standard' for Luxury packages.");
return false;
}
if (packageType === 'Couple' && !roomClass.startsWith('L')) {
alert("You can only select room classes starting with 'Lodge' for Luxury packages.");
return false;
}
if (packageType === 'Adventure' && !roomClass.startsWith('T')) {
alert("You can only select room classes starting with 'Tree House' for Luxury packages.");
return false;
}
return true;
}
function validateAdminId(adminId) {
if (adminId.length !== 5) {
return false;
}
if (adminId.charAt(0) !== adminId.charAt(0).toUpperCase()) {
return false;
}
return true;
}
//delete package
function deletePkg() {
var txt = "Are you sure you want to delete this package?";
if (confirm(txt)) {
return true; // Proceed with the deletion
} else {
return false; // Cancel the deletion
}
}