Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Flash Form with CF Validation - Not working

Guest
Sep 14, 2009 Sep 14, 2009

I've been trying to add some password validation to an existing Flash form within a CF app - I'm re-using some code in a CFC that I'm already using for a standard HTML Change Password form - which is working fine

Within the Admin section of the app there is a set of User Admin forms all held within a <cfformgroup> tags and inside a Flash form - I've tried adding the code as a call before the form is processed but it only picks up certain error conditions and I've tried putting the validation on the Submit button as an onClick event - Which is also ignored

What is the best way to do this properly - It seems such a simple task that is completely throwing me (I'm a recent convert to Coldfusion from Java so still feeling my way to a certain extent!)

My code call from the process form is

     <cfif isdefined("NewPassword") and NewPassword NEQ "">
        <cfinvoke component="global.util.PasswordUtils"
                         method="CheckPasswordStrength"
                      namedUser="#UserName#"
                      oldPassword="#Password#"
                      newPassword="#NewPassword#"
                      confirmPassword="#ConfirmPassword#"                    
                      returnvariable="passswordOK"                     
                      />

And the code within the submit onClick event is:

onClick="if( NewPassword.length > 0 ){
                         if( NewPassword.length < 8 ){    
                            alert('Password must be at least 8 characters.');
                        }else if(hash(NewPassword)==Password){
                            alert('The old and new passwords cannot be the same, please try again');
                        }else if(UserName == NewPassword){
                            alert('The username and password cannot be the same, please try again');
                        }else if(NewPassword != ConfirmPassword){
                            alert('Password and Confirmation must match, please try again');
                        }else {

                            submitForm();

                        }">

Any help would really be appreciated

Thanks

649
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 14, 2009 Sep 14, 2009
LATEST

A number of suggestions.
1) The script that runs upon onClick should be Javascript or Actionscript, not CFML(Coldfusion). So convert your script accordingly;
2) In any case, I would define the script in a function, validate() say, then do onClick="validate()";
3) You should consider using <cfform> and <cfinput>, which offer rich possibilities for clientside validation;
4) Coldfusion is handy for serverside validation. The commonest way to do so is at the form's action page. For example,

<cfset isValidationPassed = false>
<cfif isdefined("form.NewPassword") and form.NewPassword NEQ "">
    <!--- Validation of form variables goes here --->
    <!--- if validation succeeds, set isValidationPassed to true --->
    <cfif isValidationPassed>
        <cfinvoke component="global.util.PasswordUtils"
                  method="CheckPasswordStrength"
                  namedUser="#form.UserName#"
                  oldPassword="#form.Password#"
                  newPassword="#form.NewPassword#"
                  confirmPassword="#form.ConfirmPassword#"                   
                  returnvariable="passswordOK"                    
                  />
    <!--- More business code here and/or possibly redirect to another page --->
<cfelse>
    <!--- code to send client back to the form page. Give client indication why validation failed --->
</cfif>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources