-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidate.html
37 lines (32 loc) · 1.16 KB
/
validate.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
<!DOCTYPE html>
<html>
<head>
<title>Input Validation</title>
</head>
<body>
<label for="inputField">Enter a value:</label>
<input type="text" id="inputField">
<button id="validateButton">Validate</button>
<p id="validationResult"></p>
<script>
document.getElementById("validateButton").addEventListener("click", function () {
var inputValue = document.getElementById("inputField").value;
// Send the input value to the server for validation
fetch("validate_input.php", {
method: "POST",
body: JSON.stringify({ input: inputValue })
})
.then(response => response.json())
.then(data => {
var validationResult = document.getElementById("validationResult");
if (data.valid) {
validationResult.textContent = "Input is valid.";
} else {
validationResult.textContent = "Input is not valid.";
}
})
.catch(error => console.error("Error:", error));
});
</script>
</body>
</html>