0 Replies Latest reply on Apr 7, 2010 10:59 AM by malloy_david

    Automatic Password Generation on a form

    malloy_david Level 1

      I am trying to add a feature to a form that I have which will allow you to click on a button and generate a random 8 character passoword in a field or box by using java script. I am not sure about how to go about this because I am not that great at writing java script but I can read it and get a idea of what it is doing. I looked around the web and saw a few scripts that looks like it would work. But I am not sure how to get the code to run or even if it is the write code that I should be using. I know that this code works becuase I tried it in a different complier I am not sure how to get adobe acrobat pro to run the program. nor do I know how to get it to work on the pdf file. Some one please help me out.

       

       

      Here is the first code that I saw that would work:

       

       

      <form id="pform" action="">
      <table id="pgen">

      <tr><th colspan="2">Free Password Builder</th></tr>

      <tr>
      <td colspan="2"><strong>Character Set</strong></td>
      </tr>

      <tr>
      <td><input type="checkbox" id="up" name="up" checked="checked" />Upper Case<br />
      <input type="checkbox" id="lo" name="lo" checked="checked" />Lower Case</td>

      <td><input type="checkbox" id="dg" name="dg" checked="checked" />Numbers<br />
      <input type="checkbox" id="pn" name="pn" checked="checked" />Punctuation</td>
      </tr>

      <tr>
      <td colspan="2">
      <p>Additions to selection set: <input type="text" id="ct" name="ct" size="40" /></p>
      <p>Removals from selection set: <input type="text" id="rm" name="rm" size="40" /></p>
      <p><input type="text" id="le" name="le" value="8" size="3" />Length ( 1 to 128 )</p>
      </td>
      </tr>


      <tr>
      <td style="text-align:center" colspan="2">
      <p><input value="Generate Password" type="button" onclick="javascript:genpwd()" /> <input type="reset" onclick="javascript:cleanup()" /></p>
      <noscript>
      <p class="boxed">Sorry, JavaScript must be enabled in order to generate passwords. Watch this page for an enhanced version you can download and install on your local machine!</p>
      </noscript>
      <strong>Your New Password</strong>
      <p><input type="text" id="outbox" name="outbox" size="40" /></p>
      <p class="shrink">Copyright&#160;2003-2010<br /> The&#160;Bitmill<sup>&#174;</sup>&#160;Inc.<br />All Rights Reserved.</p>
      </td>
      </tr>
      </table>
      </form>


      xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

      This is the second code that I saw that would work:

       

       

       

       

      <!-- TWO STEPS TO INSTALL PASSWORD GENERATOR:

        1.  Copy the coding into the HEAD of your HTML document
        2.  Add the last code into the BODY of your HTML document  -->

      <!-- STEP ONE: Paste this code into the HEAD of your HTML document  -->

      <HEAD>

      <SCRIPT LANGUAGE="JavaScript">
      <!-- Original:  ataxx@visto.com -->

      <!-- This script and many more are available free online at -->
      <!-- The JavaScript Source!! http://javascript.internet.com -->

      <!-- Begin
      function getRandomNum(lbound, ubound) {
      return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
      }
      function getRandomChar(number, lower, upper, other, extra) {
      var numberChars = "0123456789";
      var lowerChars = "abcdefghijklmnopqrstuvwxyz";
      var upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
      var otherChars = "`~!@#$%^&*()-_=+[{]}\\|;:'\",<.>/? ";
      var charSet = extra;
      if (number == true)
      charSet += numberChars;
      if (lower == true)
      charSet += lowerChars;
      if (upper == true)
      charSet += upperChars;
      if (other == true)
      charSet += otherChars;
      return charSet.charAt(getRandomNum(0, charSet.length));
      }
      function getPassword(length, extraChars, firstNumber, firstLower, firstUpper, firstOther,
      latterNumber, latterLower, latterUpper, latterOther) {
      var rc = "";
      if (length > 0)
      rc = rc + getRandomChar(firstNumber, firstLower, firstUpper, firstOther, extraChars);
      for (var idx = 1; idx < length; ++idx) {
      rc = rc + getRandomChar(latterNumber, latterLower, latterUpper, latterOther, extraChars);
      }
      return rc;
      }
      // End -->
      </script>

      </HEAD>

      <!-- STEP TWO: Copy this code into the BODY of your HTML document  -->

      <BODY>

      <center>
      <table width=80% border=0>
      <tr align=center>
      <td>
      <form name="myform">
      <table border=0>
      <tr>
      <td>
      First character can be:
      </td>
      <td>
      <input type=checkbox name=firstNumber checked>Number
      <input type=checkbox name=firstLower checked>Lowercase
      <input type=checkbox name=firstUpper checked>Uppercase
      <input type=checkbox name=firstOther>Other
      </td>
      </tr>
      <tr>
      <td>
      Latter characters can be:
      </td>
      <td>
      <input type=checkbox name=latterNumber checked>Number
      <input type=checkbox name=latterLower checked>Lowercase
      <input type=checkbox name=latterUpper checked>Uppercase
      <input type=checkbox name=latterOther>Other
      </td>
      </tr>
      <tr>
      <td>
      Password length:
      </td>
      <td>
      <input type=text name=passwordLength value="8" size=3>
      </td>
      </tr>
      <tr>
      <td>
      Extra password characters:
      </td>
      <td>
      <input type=text name=extraChars size=20>
      </td>
      </tr>
      </table>
      </td>
      </tr>
      <tr align=center>
      <td>
      New password:
      <input type=text name=password size=20>
      <br>
      <input type=button value="Generate password" onClick="document.myform.password.value =
      getPassword(document.myform.passwordLength.value, document.myform.extraChars.value,
      document.myform.firstNumber.checked, document.myform.firstLower.checked,
      document.myform.firstUpper.checked, document.myform.firstOther.checked,
      document.myform.latterNumber.checked, document.myform.latterLower.checked,
      document.myform.latterUpper.checked, document.myform.latterOther.checked);">
      </form>
      </td>
      </tr>
      </table>
      </center>

      <p><center>
      <font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
      by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
      </center><p>

      <!-- Script Size:  3.49 KB -->