0% found this document useful (0 votes)
14 views1 page

Script Js

The document contains JavaScript code that handles the submission of a login form. It includes basic validation for username and password, simulates a successful login, and implements a 'remember me' feature using local storage. Additionally, it checks for a remembered user when the page loads and populates the username field if applicable.

Uploaded by

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

Script Js

The document contains JavaScript code that handles the submission of a login form. It includes basic validation for username and password, simulates a successful login, and implements a 'remember me' feature using local storage. Additionally, it checks for a remembered user when the page loads and populates the username field if applicable.

Uploaded by

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

[Link]('loginForm').

addEventListener('submit', function(e) {
[Link]();

const username = [Link]('username').value;


const password = [Link]('password').value;
const rememberMe = [Link]('input[name="remember"]').checked;

// Basic validation
if (!username || !password) {
alert('Please fill in all fields');
return;
}

// Add your login logic here


[Link]('Login attempted with:', { username, password, rememberMe });

// Simulate successful login


alert('Login successful! (This is a demo)');

// Clear form fields


[Link]();

// Remember me functionality
if (rememberMe) {
[Link]('rememberedUser', username);
} else {
[Link]('rememberedUser');
}
});

// Check for remembered user


[Link]('DOMContentLoaded', () => {
const rememberedUser = [Link]('rememberedUser');
if (rememberedUser) {
[Link]('username').value = rememberedUser;
[Link]('input[name="remember"]').checked = true;
}
});

You might also like