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 to set checkbox and radio option checked on load with jQuery?
Highlight and get the details of table row on click using JavaScript
Edit the text of label on click using jQuery
How to check a variable is undefined in JavaScript?
JavaScript HTML5 Validation for name and email field
JavaScript simple alert on Click
Image Rollover Using onMouseOver and onMouseOut
How to show hide option list items using jQuery?
How to scroll page to particular Div on click using jQuery?
Check if a string ends with the given target string