This is literally just an incredibly basic login form, designed to be WCAG 2.0 AA compliant.
Created
February 16, 2018 18:49
-
-
Save malcalevak/2db286cea7e6994dfd8c09a503bdf5ab to your computer and use it in GitHub Desktop.
Accessible Login Screen
This file contains 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
<form id="login"> | |
<fieldset> | |
<legend>Login</legend> | |
<div class="error" id="errors" role="alert" aria-live="assertive" aria-atomic="true"> | |
</div> | |
<label for="username" class="block">Username: | |
<input type="text" name="username" id="username" aria-required="true"> | |
</label> | |
<label for="password" class="block">Password: | |
<input type="password" name="password" id="password" aria-required="true"> | |
</label> | |
<button type="submit">Login</button> | |
</fieldset> | |
</form> |
This file contains 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
$( document ).ready(function() { | |
$('#login').on('submit',function() { | |
if($('#username').val().length === 0) { | |
$('#errors').append('<p>You must provide your username to login!</p>'); | |
} | |
if($('#password').val().length === 0) { | |
$('#errors').append('<p>You must provide your password to login!</p>'); | |
} | |
return false; | |
}) | |
}) |
This file contains 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
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> |
This file contains 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
.error { | |
color: red; | |
font-weight: bold; | |
} | |
.block { | |
display: block; | |
margin: 15px 10px; | |
} | |
legend { | |
font-size: 1.2rem; | |
font-weight: bold; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment