Clicky

I have a JavaScript routine working correctly to validate a password field.
I'm trying to replicate the Javascript to a coldfusion regular expression.
The intent is to validate both on the clinent with javascript and and on the server with cfinput.
I may be incorrect in this assumption if cfinput uses javascript to validate the form fields.
Can someone please take a look at my javascript to see if this functionallity can be created in 1 regex statement.
For example:

<cfinput type="text" name="Password" id="Password" required="yes" message="CF_Password Error! Please enter a password" size="45" maxlength="65" validate="regex" pattern="^[[email protected]##$%]{12,65}$">

Here are my password rules:
Passwords must be at least 12 characters and no greater than 65 characters long.
Passwords must be a combination of alpha and numeric characters. (myPassword3741)
Passwords must use upper AND lower case letters. (At least one of each.)
Passwords may contain these special characters  _ ! @ # $ %  (under score, exlamation, at, pound, dollar, percent)

Attached is my Javascript code.

As you can see my cfinput pattern is not good because it only allows those characters to be entered it does not check for mixed case or the presence of a number. I need to be able to trap for mixed case and make sure there is at least 1 number.

Can someone help me change the pattern on my cfinput to capture these rules in 1 statement?

asked 12/09/2011 04:25

Garbonzo_Horowitz's gravatar image

Garbonzo_Horowitz ♦♦


6 Answers:
I recall in your last question that you didn't want to combine the patterns because you wanted to give meaningful error messages. Is that not the case in your CF version?
link

answered

kaufmed's gravatar image

kaufmed

If you do want only one pattern, then you might try this:

1:
pattern="^(?=.*?[a-z])(?=.*?[A-Z])(?=.*?[0-9])[[email protected]##$%]{12,65}$"


If you don't require the digit to be mandatory, then you can remove this part:

(?=.*?[0-9])
link

answered 2011-12-09 at 12:34:35

kaufmed's gravatar image

kaufmed

That's right kaufmed. I'm breaking it down for the javascript but for the cfinput I'm trying to validate everything at once.
The special characters [email protected]#$% are not mandatory but are allowed.
I guess that's why you didn't include a lookahead for that part huh?

So the pattern you illustrate is:

must have at least 1 lower case letter
must have at least 1 upper case letter
must have at least 1 digit number
can have lower case letters as well as upper case letters , digits 0-9 and the special charaters.
with a lengt between 12 and 65.

Thank you very much.
link

answered 2011-12-09 at 12:38:37

Garbonzo_Horowitz's gravatar image

Garbonzo_Horowitz

Thank you
link

answered 2011-12-09 at 12:57:47

Garbonzo_Horowitz's gravatar image

Garbonzo_Horowitz

I guess that's why you didn't include a lookahead for that part huh?

Yes.

Glad to help  = )
link

answered 2011-12-09 at 12:58:49

kaufmed's gravatar image

kaufmed

<hijack>
    Hi @kaufmed - If you're hanging around, any ideas for a regex to add missing </td>
    tags? http://www.qa.downappz.com/Web_Development/Web_Languages-Standards/Cold_Fusion_Markup_Language/Q_27492023.html
</hijack>
link

answered 2011-12-09 at 13:00:33

_agx_'s gravatar image

_agx_

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×4
×32
×8
×11
×4
×9

Asked: 12/09/2011 04:25

Seen: 336 times

Last updated: 12/09/2011 04:58