You are tasked with building a user authentication form where users can log in by providing their username and password. The authentication process should simulate a delay of 2 seconds and return a promise based on validating the credentials.
Upon clicking the Login button, display a message Authenticating in the p
tag with the class status-message
with a blue
font color indicating the process has started. Make sure to clear all the spaces in the username and password before validating.
The credentials should be validated to ensure the username is admin
and the password is $to7Meer!2
. If the validation is successful, the promise should resolve with the message, Welcome, Admin! . If the validation fails, the promise should reject with the message, Authentication failed! Invalid credentials. . The success and failure messages should be displayed in the p
tag with the class status-message
, styled with a green
and red
font color respectively.
Additionally, make sure the message Authentication process completed. is displayed in the p
tag with the class completion-message
and styled with a darkgray
font color, regardless of whether the authentication succeeds or fails. This message should automatically disappear after 3 seconds.
We are not displaying the answer for this exercise.
We do this because we want you to challenge yourself
and
not give in to the temptation of looking at the solution.
We also don't want to leave you stuck, so if you feel
you have tried enough and are still unable to solve
this exercise, feel free to ask in our community.
Here is the link to join the community.