jQuery Hands-on 2 - Login Page
jQuery > jQuery Event Handling > jQuery Event Handling
529
Answer:
1. jQuery Hands-on 2 - Login Page
Write a function login() that will read the username and password from the text boxes IDs #username, #password, and validate them.
For username="admin" and password= "password", create an alert box "You are a valid user", or "You are not a valid user".
index.htmlscript.js
function login() { };
script.js
Here is the implementation of the login function in JavaScript:
function login() { var username = $("#username").val(); var password = $("#password").val(); if (username == "admin" && password == "password") { alert("You are a valid user"); } else { alert("You are not a valid user"); } };
This Particular section is dedicated to Question & Answer only. If you want learn more about jQuery. Then you can visit below links to get more depth on this subject.
Join Our telegram group to ask Questions
Click below button to join our groups.