Skip to main content
Known Participant
May 7, 2010
Question

Password Validation/Confirmation

  • May 7, 2010
  • 1 reply
  • 4082 views

I've tried several ways to go about doing this, but I keep running into snags one place or another.

I have a CF 8 Flash form.  On this part of the page I'm making a form for them to request setting up an e-mail account.  In it's current form, the form does not load at all, this happened when I put the onClick into the submit button.  It has also previously happened when I tried an onsubmit in the cfform tag.  I hardly know anything about Javascript, and have been trying to piece together examples from out on the internet to get this to do what I need it to do. (Check password for 8 characters, must have special character/number, must input same password twice on the page).  I apparently can't use Spry because I'm locked in to having to use a flash form.

It's current form would meet all but the special character requirement, but as I said before, the form comes up completely blank at the moment, almost just like it does if you forget to name a field.  Can anyone shed some light into this behavior?

Here's the code, this particular form is just one in a tabbed page.

<script language="javascript" type="text/javascript">
    function checkPassword() {
      var strng  = document.emailSetup.mailPass.value;
      var strng2 = document.emailSetup.confirmPass.value;
      var errMsg = "";
      if (strng == "") {
            errMsg = "Enter a password.\n";
      }

      if ((strng.length < 😎 || (strng.length > 100)) {
            errMsg += "The password is the wrong length\n";
      }

      if (!/[0-9]/.test(strng) || !/[a-zA-Z]/.test(strng)) {
            errMsg += "The password must contain at least one letter and one numeral.\n";
      }

      if(strng!=strng2)
            errMsg += "Your passwords do not match!\n";
     
      if(errMsg==''){
            return true;
      } else {
            alert(errMsg);
            return false;
      }
return false;

}
</script>

    <cflayoutarea title="Set up New E-mail" overflow="hidden">
        <cfform format="flash" name="emailSetup" timeout="300" skin="haloblue" action="emailAction.cfm">
            <cfformgroup type="panel" label="ADSS Helpdesk" height="390" style="text-align:left; color:##000000; font-size:12;">
                <cfinput type="text" name="empName" label="New Employee's Name" width="250" required="yes">
                   <cfselect name="agencyID" width="150" label="Agency:">
                    <cfoutput query="agencyFetch">
                           <option value="#agencyID#">#agency#</option>
                       </cfoutput>
                </cfselect>
                <cfinput type="password" name="mailPass" width="100" label="Desired Password" required="yes">
                <cfinput type="password" name="confirmPass" width="100" label="Confirm Password" required="yes">               
                <cfselect name="capacity" label="Mailbox Capacity:" width="150">
                    <option value="250">250 MB ($6.50)</option>
                    <option value="500">500 MB ($12.00)</option>
                    <option value="1500">1500 MB ($25.00)</option>
                </cfselect>
                <cfformgroup type="horizontal" label="Requester's Name">
                    <cfinput type="text" name="reqFName" width="100" required="yes">
                    <cfinput type="text" name="reqLName" width="100" required="yes">
                </cfformgroup>
                <cfinput type="text" name="reqEmail" label=" Requester's Email:" width="300" bind="{reqFName.text.toLowerCase()}.{reqLName.text.toLowerCase()}@adss.alabama.gov" required="yes">           
                <cfinput type="submit" name="mailSubmit" value="Request Email Address" onClick="checkPassword()">                               
               </cfformgroup>
        </cfform>
    </cflayoutarea>

    This topic has been closed for replies.

    1 reply

    rdhelmsAuthor
    Known Participant
    May 11, 2010

    any takers?


    Inspiring
    May 11, 2010

    If you are using a flash form, you will need to use actionscript, not javascript. You can add actionscript functions using cfformitem type="script".

    http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/

    rdhelmsAuthor
    Known Participant
    May 19, 2010

    I've got the part where it checks to see if the passwords match working correctly now. I used this in the cfform.

    onsubmit="if(mailPass.text != confirmPass.text) {alert('Passwords do not match'); return false;}">

    I'm still hitting a wall on the Complexity validation though, since I can't use the regular_expression validation from cfinput in a flash form either.  Thanks for the actionscript pointer however, it led me to find atleast half of the solution.  I can't seem to find any examples of people doing this in actionscript online however.