<!DOCTYPE html>
<html>
<head>
<title>Textbox Validation</title>
<script>
function validateTextBox() {
var name = document.getElementById("txtName").value;
if (name.trim() === "") {
alert("Please enter your name.");
return false;
}
alert("Submitted Successfully!");
return true;
}
</script>
</head>
<body>
<label>Name:</label>
<input type="text" id="txtName">
<br><br>
<button onclick="validateTextBox()">Submit</button>
</body>
</html>
No comments:
Post a Comment