File size: 726 Bytes
76caa2b
 
0883572
76caa2b
0883572
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76caa2b
 
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
<!DOCTYPE html>
<html>
<head><title>OTP Validator</title></head>
<body>
  <h2>🔐 OTP Validator</h2>
  <form id="otp-form">
    <input type="text" name="otp" placeholder="Enter OTP" required />
    <button type="submit">Validate</button>
  </form>
  <div id="result"></div>

  <script>
    document.getElementById("otp-form").onsubmit = async (e) => {
      e.preventDefault();
      const otp = e.target.otp.value;
      const res = await fetch("/validate", {
        method: "POST",
        headers: {"Content-Type": "application/json"},
        body: JSON.stringify({otp}),
      });
      const data = await res.json();
      document.getElementById("result").innerText = data.message;
    };
  </script>
</body>
</html>