forked from anuragverma108/SwapReads
-
Notifications
You must be signed in to change notification settings - Fork 0
/
address.html
59 lines (49 loc) · 1.97 KB
/
address.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit Address</title>
<link rel="stylesheet" href="/address.css">
</head>
<body>
<body>
<div class="container">
<h2>Enter Address</h2>
<form id="address-form">
<div class="form-group">
<label for="address">Address:</label>
<input type="text" id="address" placeholder="Enter your address" maxlength="28">
</div>
<button id="submit-btn">Submit</button>
<button type="button" class="back-btn" onclick="history.back()">Back</button>
</form>
<div id="message" class="message"></div>
</div>
<script>
const form = document.getElementById('address-form');
const addressInput = document.getElementById('address');
const submitBtn = document.getElementById('submit-btn');
const messageDiv = document.getElementById('message');
// Load the saved address from localStorage when the page loads
window.onload = () => {
const savedAddress = localStorage.getItem('address');
if (savedAddress) {
addressInput.value = savedAddress;
}
};
submitBtn.addEventListener('click', (e) => {
e.preventDefault();
const address = addressInput.value.trim();
if (address) {
localStorage.setItem('address', address);
messageDiv.textContent = 'Address saved successfully!';
messageDiv.style.color = 'green';
} else {
messageDiv.textContent = 'Please enter an address!';
messageDiv.style.color = 'red';
}
});
</script>
</body>
</html>