0% found this document useful (0 votes)
25 views2 pages

Ex No - 9

Uploaded by

dominichendry28
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

Ex No - 9

Uploaded by

dominichendry28
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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>

You might also like