?
Solved

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

Posted on 2009-05-08
6
Medium Priority
?
528 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
A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?

 
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

Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

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, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month9 days, 16 hours left to enroll

762 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