Solved

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

Posted on 2009-05-08
6
526 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 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
Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

 
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

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

717 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