tiagovareta
Member
Hi,
I added a button element on my form. This button executes a javascript code to create a random password:
function randomPassword(length) {
var chars = "abcdefghijklmnopqrstuvwxyz#$%&BCDEFGHIJKLMNOP1234567890";
var pass = "";
for (var x = 0; x < length; x++) {
var i = Math.floor(Math.random() * chars.length);
pass += chars.charAt(i);
}
return pass;
}
The thing is that I wanted to click the button, the generated password was assigned to the value of the password field (password_ctg).
How can I assign the generated value to the field using javascript?
I added a button element on my form. This button executes a javascript code to create a random password:
function randomPassword(length) {
var chars = "abcdefghijklmnopqrstuvwxyz#$%&BCDEFGHIJKLMNOP1234567890";
var pass = "";
for (var x = 0; x < length; x++) {
var i = Math.floor(Math.random() * chars.length);
pass += chars.charAt(i);
}
return pass;
}
The thing is that I wanted to click the button, the generated password was assigned to the value of the password field (password_ctg).
How can I assign the generated value to the field using javascript?