Solved

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

Posted on 2009-05-08
6
507 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 15

Expert Comment

by:myselfrandhawa
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 15

Expert Comment

by:myselfrandhawa
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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 15

Expert Comment

by:myselfrandhawa
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now