Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="" />
<meta charset=utf-8 />
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.min.css" rel="stylesheet">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/js/bootstrap.min.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
</head>
<body>
  <hr>
  Length: <input id="passlength"/><br>
  Password: <input id="password"/><br>
  <button class="btn btn-info" id="generate">Generate Password</button>
  
</body>
</html>
  
 
$(document).ready(function() {
$("#generate").click(function() {
  getNewPassword();
});
function random(min, max) {
    return min + parseInt(Math.random() * (max - min + 1), 10);
}
function generatePassword(charset) {
    var length = parseInt($("#passlength").val(), 10);
    console.log(length);
    var password = "";
    while (length--) {
        password += charset[random(0, charset.length - 1)];
    }
    return password;
}
function getNewPassword() {
      var pass = generatePassword("AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789!?#@*&.,;:+-=()[]_");
  console.log(pass);
  $('#password').val(pass);
}
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
alex.daquinopro
0viewers