0
Determine if a new password is alphanumeric
LEGEND
,
/t5/coldfusion-discussions/determine-if-a-new-password-is-alphanumeric/td-p/1041215
Sep 26, 2006
Sep 26, 2006
Copy link to clipboard
Copied
What is the best way to determine in coldfusion if a user has
created an
alphanumeric password?
alphanumeric password?
TOPICS
Advanced techniques
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Engaged
,
/t5/coldfusion-discussions/determine-if-a-new-password-is-alphanumeric/m-p/1041216#M94148
Sep 26, 2006
Sep 26, 2006
Copy link to clipboard
Copied
<cfif REFind("[^a-zA-Z0-9]", passwordstring)>
-- code to do whatever with password if it is alphanumeric
<cfelse>
code to do whatever with password if it is not all alphanumeric
</cfif>
You can also use:
<cfif REFind("[[:alnum:]]", "passwordstring") >
-- code to do whatever with password if it is alphanumeric
<cfelse>
code to do whatever with password if it is not all alphanumeric
</cfif>
You can also use:
<cfif REFind("[[:alnum:]]", "passwordstring") >
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
/t5/coldfusion-discussions/determine-if-a-new-password-is-alphanumeric/m-p/1041217#M94149
Sep 26, 2006
Sep 26, 2006
Copy link to clipboard
Copied
thanks for the tip
<cfif #REfind("[^a-zA-Z0-9]", password)#>
<cfoutput>#password#</cfoutput>Password is alphanumeric
<cfelse>
<cfoutput>#password#</cfoutput>Password in not alphanumeric</cfif>
I took your advice and I cant seem to get it working. Is my syntax wrong?
Password is a form variable
the above code always produces password is not alphanumic after
entering 111aaa as password
"Abinidi" <webforumsuser@macromedia.com> wrote in message
news:efcco0$t8n$1@forums.macromedia.com...
> <cfif REFind("[^a-zA-Z0-9]", passwordstring)>
> -- code to do whatever with password
> <cfelse>
> code to reject users password
> </cfif>
>
> You can also use:
>
> <cfif REFind("[[:alnum:]]", "passwordstring") >
>
>
>
<cfif #REfind("[^a-zA-Z0-9]", password)#>
<cfoutput>#password#</cfoutput>Password is alphanumeric
<cfelse>
<cfoutput>#password#</cfoutput>Password in not alphanumeric</cfif>
I took your advice and I cant seem to get it working. Is my syntax wrong?
Password is a form variable
the above code always produces password is not alphanumic after
entering 111aaa as password
"Abinidi" <webforumsuser@macromedia.com> wrote in message
news:efcco0$t8n$1@forums.macromedia.com...
> <cfif REFind("[^a-zA-Z0-9]", passwordstring)>
> -- code to do whatever with password
> <cfelse>
> code to reject users password
> </cfif>
>
> You can also use:
>
> <cfif REFind("[[:alnum:]]", "passwordstring") >
>
>
>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
/t5/coldfusion-discussions/determine-if-a-new-password-is-alphanumeric/m-p/1041218#M94150
Sep 27, 2006
Sep 27, 2006
Copy link to clipboard
Copied
Can you clarify the requirement. Are you after passwords that
are ONLY
alphanumeric (ie: must only contain a-z and 0-9, but no other characters),
or passwords that must have at least some alphanumeric characters in them
(so all alpha is no good, nor is all numeric).
The orginal regex matches any character that is not a-zA-Z0-9, so you have
your logic around the wrong way. If it DOES return a match, the pwd has a
non alpha-numeric character in it.
--
Adam
alphanumeric (ie: must only contain a-z and 0-9, but no other characters),
or passwords that must have at least some alphanumeric characters in them
(so all alpha is no good, nor is all numeric).
The orginal regex matches any character that is not a-zA-Z0-9, so you have
your logic around the wrong way. If it DOES return a match, the pwd has a
non alpha-numeric character in it.
--
Adam
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/determine-if-a-new-password-is-alphanumeric/m-p/1041219#M94151
Sep 27, 2006
Sep 27, 2006
Copy link to clipboard
Copied
Regular expressions are not my strong suit, but, don't you
have that backwards?
If I do this.
<cfset x = REFind("[^a-zA-Z0-9]", "passwordstring")>
<cfdump var="#x#">
I get 0
If I do this:
<cfset x = REFind("[^a-zA-Z0-9]", "pas*swordstring")>
<cfdump var="#x#">
I get 4
If I do this.
<cfset x = REFind("[^a-zA-Z0-9]", "passwordstring")>
<cfdump var="#x#">
I get 0
If I do this:
<cfset x = REFind("[^a-zA-Z0-9]", "pas*swordstring")>
<cfdump var="#x#">
I get 4
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
/t5/coldfusion-discussions/determine-if-a-new-password-is-alphanumeric/m-p/1041220#M94152
Sep 27, 2006
Sep 27, 2006
Copy link to clipboard
Copied
Hi Adam, thanks for the note. Im trying to make sure that new
users register
to use my web site with an alphanumeric password.
That is, their password must contain letters and numbers.
"Adam Cameron" <adam_junk@hotmail.com> wrote in message
news:5e0tx0nksh9s.54x4xll3pziy.dlg@40tude.net...
> Can you clarify the requirement. Are you after passwords that are ONLY
> alphanumeric (ie: must only contain a-z and 0-9, but no other characters),
> or passwords that must have at least some alphanumeric characters in them
> (so all alpha is no good, nor is all numeric).
>
> The orginal regex matches any character that is not a-zA-Z0-9, so you have
> your logic around the wrong way. If it DOES return a match, the pwd has a
> non alpha-numeric character in it.
>
> --
> Adam
to use my web site with an alphanumeric password.
That is, their password must contain letters and numbers.
"Adam Cameron" <adam_junk@hotmail.com> wrote in message
news:5e0tx0nksh9s.54x4xll3pziy.dlg@40tude.net...
> Can you clarify the requirement. Are you after passwords that are ONLY
> alphanumeric (ie: must only contain a-z and 0-9, but no other characters),
> or passwords that must have at least some alphanumeric characters in them
> (so all alpha is no good, nor is all numeric).
>
> The orginal regex matches any character that is not a-zA-Z0-9, so you have
> your logic around the wrong way. If it DOES return a match, the pwd has a
> non alpha-numeric character in it.
>
> --
> Adam
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Engaged
,
/t5/coldfusion-discussions/determine-if-a-new-password-is-alphanumeric/m-p/1041221#M94153
Sep 27, 2006
Sep 27, 2006
Copy link to clipboard
Copied
i am afraid Abidini did get it the other way around and
confused oyu with that.
Correct sequence should be:
<cfif REFind("[^a-zA-Z0-9]", passwordstring)><!--- NO alphanumeric characters in passwordstring --->
.....
<cfelse><!--- passwordstring contains an alphanumeric character --->
....
</cfif>
if you are using <cfform> and <cfinput> tags in your form, then you can use CF validation on your password field:
<cfinput type="text" validate="regex" pattern="^[a-zA-Z0-9]*$" required="yes" message="your message to display if validation fails">
you must be using CFMX7 for this to work, though...
Correct sequence should be:
<cfif REFind("[^a-zA-Z0-9]", passwordstring)><!--- NO alphanumeric characters in passwordstring --->
.....
<cfelse><!--- passwordstring contains an alphanumeric character --->
....
</cfif>
if you are using <cfform> and <cfinput> tags in your form, then you can use CF validation on your password field:
<cfinput type="text" validate="regex" pattern="^[a-zA-Z0-9]*$" required="yes" message="your message to display if validation fails">
you must be using CFMX7 for this to work, though...
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/coldfusion-discussions/determine-if-a-new-password-is-alphanumeric/m-p/1041222#M94154
Oct 03, 2006
Oct 03, 2006
Copy link to clipboard
Copied
BJ,
The regular expressions given (like "^[a-zA-Z0-9]$" are just ensuring that the string contains only letters or numbers, but not forcing the inclusion of at least one of each.
My thought was the string must either be:
<stuff 1><one letter><stuff 2><one digit><stuff 3>
or
<stuff 1><one digit><stuff 2><one letter><stuff 3>
where stuff 1, stuff 2, and stuff 3 are arbitrary (possibly empty) alphanumeric strings.
The regex for this is:
"^([a-zA-Z0-9]*[a-zA-Z][a-zA-Z0-9]*[0-9][a-zA-Z0-9]*|[a-zA-Z0-9]*[0-9][a-zA-Z0-9]*[a-zA-Z][a-zA-Z0-9]*)$"
The pipe "|" in the middle separates the two cases (the letter occurs before the number | the number occurs before the letter).
The ^ denotes the beginning of the string, and the $ denotes the end, so this RE will always return 1 if the password is OK, and zero otherwise.
The regular expressions given (like "^[a-zA-Z0-9]$" are just ensuring that the string contains only letters or numbers, but not forcing the inclusion of at least one of each.
My thought was the string must either be:
<stuff 1><one letter><stuff 2><one digit><stuff 3>
or
<stuff 1><one digit><stuff 2><one letter><stuff 3>
where stuff 1, stuff 2, and stuff 3 are arbitrary (possibly empty) alphanumeric strings.
The regex for this is:
"^([a-zA-Z0-9]*[a-zA-Z][a-zA-Z0-9]*[0-9][a-zA-Z0-9]*|[a-zA-Z0-9]*[0-9][a-zA-Z0-9]*[a-zA-Z][a-zA-Z0-9]*)$"
The pipe "|" in the middle separates the two cases (the letter occurs before the number | the number occurs before the letter).
The ^ denotes the beginning of the string, and the $ denotes the end, so this RE will always return 1 if the password is OK, and zero otherwise.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Newsgroup_User
AUTHOR
LEGEND
,
LATEST
/t5/coldfusion-discussions/determine-if-a-new-password-is-alphanumeric/m-p/1041223#M94155
Oct 04, 2006
Oct 04, 2006
Copy link to clipboard
Copied
The regex for this is:
"^([a-zA-Z0-9]*[a-zA-Z][a-zA-Z0-9]*[0-9][a-zA-Z0-9]*|[a-zA-Z0-9]*[0-9][a-zA-Z0-9
]*[a-zA-Z][a-zA-Z0-9]*)$"
I would probably have done this like this:
<cfif refind("[a-z]"...) AND refind("[A-Z]"...) AND refind("[0-9]"...)...>
I'm sure they both work :-)
"^([a-zA-Z0-9]*[a-zA-Z][a-zA-Z0-9]*[0-9][a-zA-Z0-9]*|[a-zA-Z0-9]*[0-9][a-zA-Z0-9
]*[a-zA-Z][a-zA-Z0-9]*)$"
I would probably have done this like this:
<cfif refind("[a-z]"...) AND refind("[A-Z]"...) AND refind("[0-9]"...)...>
I'm sure they both work :-)
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

