Example
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form name="myform" method="post" action="">
<input name="row_password" type="text" size="40">
<input type="button" class="button" value="Generate" onClick="randomPassword(10);" tabindex="2">
</form>
<script>
function randomPassword(length) {
var chars = "abcdefghijklmnopqrstuvwxyz!@#$%^&*()-+<>ABCDEFGHIJKLMNOP1234567890";
var pass = "";
for (var x = 0; x < length; x++) {
var i = Math.floor(Math.random() * chars.length);
pass += chars.charAt(i);
}
myform.row_password.value = pass;
}
</script>
</body>
</html>
Most Helpful This Week
How can I redirect the user from one page to another using jQuery or pure JavaScript?
How to declare and print value of variable in JavaScript?
JavaScript HTML5 Validation for name and email field
How to the length of the longest word in the provided sentence?
How to declare multiple variables in one statement in Javascript?
JavaScript check if first string contains all characters of second string