Ex no:9 Write a program to validate the user using VB script with HTML form element
Aim : write it own
Algorithm: write it own
Program
<!DOCTYPE html>
<html>
<head>
<title>User Login Validation</title>
</head>
<body>
<h2>Login Form</h2>
<form>
Username: <input type="text" id="username"><br><br>
Password: <input type="password" id="password"><br><br>
<input type="button" value="Login" onclick="ValidateUser()">
</form>
<p id="result"></p>
<script language="VBScript">
Sub ValidateUser()
Dim inputUsername, inputPassword
Dim validUsername, validPassword
' Predefined valid credentials
validUsername = "admin"
validPassword = "password123"
' Get user input from form fields
inputUsername = Document.getElementById("username").value
inputPassword = Document.getElementById("password").value
' Validate the input against the predefined credentials
If inputUsername = validUsername And inputPassword = validPassword Then
Document.getElementById("result").innerHTML = "Login successful! Welcome, " & inputUsername
& "."
Else
Document.getElementById("result").innerHTML = "Invalid username or password. Please try again."
End If
End Sub
</script>
</body>
</html>