Solved

Need reg exp to validate 6 to 10 char password in ColdFusion

Posted on 2009-05-08
6
518 Views
Last Modified: 2012-05-06
Hi

Could someone show me how to write a regular expression to validate a password field in a <CFINPUT>

I want to allow any 6 to 10 character alpha numeric.

No spaces, special char etc.  

Upper and lower case are Ok

Most important is length must be  >= 6 char and <+ 10 char

Thanks
Mike
0
Comment
Question by:bigmikey88
  • 3
  • 2
6 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 24341097
Something like this would work.  But you should obviously do server side validation as well.
<cfform>
	<!--- using type="text" for demonstration purposes only --->
	Password 
	<cfinput type="text" name="testPassword" 
			validate="regex" 
			pattern="^[a-zA-Z0-9]{6,10}$"
			required="true"
			message="Password must be alphanumeric and 6 to 10 characters in length"> 
	<cfinput type="submit" name="submitButton"> 
</cfform>

Open in new window

0
 
LVL 16

Expert Comment

by:Gurpreet Singh Randhawa
ID: 24342808
here is th eone you would like to try:<input id="gwProxy" type="hidden"><!--Session data--><input onclick="jsCall();" id="jsProxy" type="hidden">
cfinput name="a_pass" type="password" required="yes" message="Error! Provide valid password aleast 6 characters and a number" validate="regular_expression" pattern="(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{6,20})$">

Open in new window

0
 
LVL 16

Expert Comment

by:Gurpreet Singh Randhawa
ID: 24342814
ignore this my browser problem<input id="gwProxy" type="hidden"><!--Session data--><input onclick="jsCall();" id="jsProxy" type="hidden">
<input id="gwProxy" type="hidden"><!--Session data--><input onclick="jsCall();" id="jsProxy" type="hidden">

Open in new window

0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
LVL 52

Expert Comment

by:_agx_
ID: 24344332
> <cfinput  ... validate="regular_expression" pattern="(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{6,20})$">

That does not produce the results: length must be  >= 6 char and <+ 10 char
0
 
LVL 16

Expert Comment

by:Gurpreet Singh Randhawa
ID: 24344381
that he can in the last where it was comprising 6,20.

ootherwise i think pattern is ok
0
 

Author Closing Comment

by:bigmikey88
ID: 31579675
thanks the regex worked
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question