jQuery Hands-on 2 - Login Page
Fill In The Blank
Views 471
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"); } };
Related Articles:
This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of jQuery, click the links and dive deeper into this subject.
Join Our telegram group to ask Questions
Click below button to join our groups.