[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

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

Posted on 2009-05-08
6
Medium Priority
?
535 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 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
How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

650 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