-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate.js
More file actions
24 lines (20 loc) · 788 Bytes
/
validate.js
File metadata and controls
24 lines (20 loc) · 788 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function validateTicket() {
const numberInput = document.getElementById('numberInput');
const resultDiv = document.getElementById('result');
// Check if a ticket number is entered
if (numberInput.value.trim() === '') {
alert('Please enter a ticket number.');
return;
}
// Retrieve the name from local storage based on the entered ticket number
const name = localStorage.getItem(numberInput.value);
if (name) {
// Display the result
resultDiv.innerHTML = `<p><strong>Name:</strong> ${name}</p>`;
} else {
// Display an error message
resultDiv.innerHTML = '<p><strong>Error:</strong> Invalid ticket number.</p>';
}
// Clear the input field
numberInput.value = '';
}