Created
September 27, 2023 07:29
-
-
Save stokito/4ce59aa2772d4ac0a22091d2be5c3672 to your computer and use it in GitHub Desktop.
HTML5 login form Bootstrap and JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<script src="https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js" crossorigin="anonymous"></script> | |
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous"/> | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script> | |
<title>Login to admin panel</title> | |
<script> | |
window.addEventListener('load', (event) => { | |
$('#loginModal').modal('show') | |
}) | |
function signIn() { | |
let username = document.getElementById('username').value.toLowerCase().trim() | |
let password = document.getElementById('password').value.trim() | |
console.log(username + ' ' + password) | |
return false | |
} | |
</script> | |
</head> | |
<body> | |
<div class="modal fade in" id="loginModal" tabindex="-1" aria-labelledby="loginModalLabel" role="dialog"> | |
<div class="modal-dialog"> | |
<div class="modal-content"> | |
<div class="modal-header"> | |
<h5 class="modal-title" id="loginModalLabel">Login</h5> | |
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> | |
</div> | |
<div class="modal-body"> | |
<form onsubmit="return signIn(event)"> | |
<div class="form-group"> | |
<label for="username">Username</label> | |
<input type="text" class="form-control" id="username" pattern="[A-Za-z0-9\.-_]+" required> | |
</div> | |
<div class="form-group"> | |
<label for="password">Password</label> | |
<input type="password" class="form-control" id="password" required> | |
</div> | |
<button type="submit" class="btn btn-primary">Sign in</button> | |
</form> | |
</div> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment