Password Validation/Confirmation
Copy link to clipboard
Copied
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 < 8) || (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>
Copy link to clipboard
Copied
any takers?
Copy link to clipboard
Copied
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/
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Have you considered using an html form? I have yet to see anything good about flash forms.
Copy link to clipboard
Copied
Have you considered using an html form? I have yet to see
anything good about flash forms.
I think they used to be more popular. But these days, most people use html forms.
Copy link to clipboard
Copied
I agree. Unfortunately, this is what I have to work with. I had a spry version in HTML and had to change it to flash earlier.
Copy link to clipboard
Copied
Well, I've made a little progress I believe, I'm almost there, just some syntax problems now I think. I modified a Password Strength checker I found to try and bend it to my purposes, and have tried to add it in the cfformitem="script" I'm not quite sure how it's supposed to work yet with nothing that just comes out and says function() to call, but that's something the actionscript boys will hopefully be able to help me with.
Here's the code as it is now.
<cflayoutarea title="Set up New E-mail" overflow="hidden">
<cfform format="flash" name="emailSetup" timeout="300" skin="haloblue" action="emailAction.cfm" onsubmit="passwordChecker">
<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>
<cfformitem type="script">
package passwordChecker
{
public class passwordStrength
{
private static var _strength : Number = 0;
private static var _regAlpha : RegExp = new RegExp( /([a-Z]+)/ );
private static var _regLength : RegExp = new RegExp( /(?=^.{8,}$)/);
private static var _regNum : RegExp = new RegExp( /([0-9]+)/ );
private static var _regSpecial : RegExp = new RegExp( /(\W+)/ );
public static function checkStrength( mailPass : String ) : Number
{
_strength = 0;
if( mailPass.search( _regAlpha ) != -1 )
{
_strength ++;
}
if( mailPass.search( _regLength ) != -1 )
{
_strength ++;
}
if( mailPass.search( _regNum ) != -1 )
{
_strength ++;
}
if( mailPass.search( _regSpecial ) != -1 )
{
_strength ++;
}
if _strength < 4
{
alert('Passwords does not meet requirements');
}
if(mailPass.text != confirmPass.text)
{
alert('Passwords do not match');
}
return false;
}
}
}
</cfformitem>
<cfinput type="text" name="mailPass" width="100" label="Desired Password" required="yes">
<cfinput type="text" 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">
</cfformgroup>
</cfform>
</cflayoutarea>
Copy link to clipboard
Copied
That is a full fledged action script class, not a function. It is been a while since I have used flash forms. But IIRC you may be able to import existing classes. Then use the class' static methods.
Keep in mind flash forms are limited. There are certain keywords you cannot use, etcetera. So you are not going have the full range of flex/action script capabilities. You might want to check the older flash articles on asfusion.com. It was quite a good resource for flash forms at the height of their popularity.
http://www.asfusion.com/
Message was edited by: -==cfSearching==-
Copy link to clipboard
Copied
I can't seem to find any examples of
people doing this in actionscript online however.
I could be wrong, but I think regular expressions were not even supported in early versions of action script, which could explain the lack of examples.
While not the most elegant solution, you could probably achieve the same effect using basic string functions. Verify the length of the password string. Then loop through each character. Search for the index of that character in a list of upper/lowercase letters. If the current character is found, set a flag (ie boolean variable). Do the same for numbers. Then check the results to determine if the password meets your conditions of one (1) letter and number.

