Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8499979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:48:51+00:00 2026-06-11T00:48:51+00:00

I have a form for adding a new username and password to a site.

  • 0

I have a form for adding a new username and password to a site. I’m trying to add a button which generates a 12character password and puts it into the password text box. Everytime this button is pressed it should delete the password in already and add in another 12 char password.

This is my layout:
http://snag.gy/L4woo.jpg

Here is how my form:

<form method="post" action="addNewLogin.php" name="addUserLoginForm" id="addUserLoginForm" onsubmit= "return validateNewLoginForm()" >
    <input type="hidden" name="submitAttempt" value="true"/>
    <table style="background-color: White; padding:20px;" align="center">
                    <tr>
            <td style="width:180px;">
                        <label style="margin-left:400px;">Username</label>
                    </td>
                    <td style="width:420px;">
                                <input name="username" type="text" style="width:140px;" onchange= "return usernameValidation(this)" />
                    </td> 
        </tr>
        <tr>
                    <td>
                        <label style="margin-left:400px;">Password</label>
                    </td>
                    <td>
                        <input name="password" type="password" style="width:140px;" onchange= "return passwordValidation(this)"/>
                    </td>
                            <td style="margin-right: 200px;">
                                <button type="password" type= "text" onclick="return generateKey()">Generate Password!</button>
                            </td>
        </tr>
        </table>
<div align="center"><input type="submit" value="Add Login Details For New User" /></div>
</form>

My usernames and password validate through a separate JavaScript function using standard regex

And here is my 12character generate password function:

public function generateKey()
{
        $random_bytes = openssl_random_pseudo_bytes(9);
        $random_string = mysql_escape_string(str_replace(array(1 => "+",2 => "/"), array(1 => "-", 2 => "_"), base64_encode($random_bytes)));
        return $random_string;
}

I have no idea how to click on this button to apply this function to the required textbox. hope you can help. thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:48:53+00:00Added an answer on June 11, 2026 at 12:48 am

    Why do you generate the new password on your server?
    Simply generate your password client-side with javascript!

    Edit:
    Here is a quick example on how to do that with JS and jQuery

    http://jsfiddle.net/kannix/KhWR4/

    and please refactor your html code <button type="password" is non valid html 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TreeView control on a form. I am dynamically adding new TreeNodes
I have an ASP.NET MVC form for adding a module to a site. The
I have a TabControl , to which I am programmatically adding a Form with
I have registration form, which is saving user info in 'tblusers' -> 'Username', but
I have a form for adding new students to a Database and a php
I'm developing an app for iPad. I have a form (UIViewController) for adding new
I have a jsp as my view, which displays a form for adding a
The green plus sign button for adding new instances in the admin form disappears
I have a html form for adding new places in my data , I
I have a simple form for generating reports that I am adding a jqueryUI

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.