Skip to content

Instantly share code, notes, and snippets.

@ravishtiwari
Created June 11, 2015 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ravishtiwari/9d74b7d8c8534cbef9ed to your computer and use it in GitHub Desktop.
Save ravishtiwari/9d74b7d8c8534cbef9ed to your computer and use it in GitHub Desktop.
Example Accessible Modal Dialog
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="http://getbootstrap.com/favicon.ico">
<title>Accessible Modal Dialogs</title>
<!-- Bootstrap core CSS -->
<link href="http://getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="container-fluid">
<h1>Dialog Example</h1>
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="modalTitle" aria-describedby="modalDescription" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h1 id="modalTitle" class="sr-only">Address Form</h1>
</div>
<div class="modal-body">
<div role="document">
<div id="modalDescription" class="sr-only">
Beginning of dialog window. Demo of accessible Modal dialog. Escape will cancel and close the window.
</div>
<form name="form1" method="post" action="">
<p>
<label for="address">Address</label>
<input name="address" id="address" type="text">
</p>
<p>
<label for="City">City</label>
<input name="City" id="City" type="text">
</p>
<p>
<label for="zip">Zip</label>
<input name="zip" id="zip" type="text">
</p>
</form>
</div> <!-- Matching div for optional role="document" -->
</div>
<div class="modal-footer">
<a href="javascript:;" data-dismiss="modal">Close</a>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>
</div><!-- /.container -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="http://getbootstrap.com/dist/js/bootstrap.min.js"></script>
<script type="text/javascript">
$('#myModal').on('shown.bs.modal', function () {
window.setTimeout(function(){
//$("#address").focus();
}, 10);
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment