Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Need help validating a form field server side

New Here ,
Apr 13, 2010 Apr 13, 2010

Sorry for the entry level question but how can I validate a text field server side

to check if it contains at least one capital letter, one number and one character?

Thanks

TOPICS
Getting started
716
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 15, 2010 Apr 15, 2010

andy99 wrote:

Sorry for the entry level question but how can I validate a text field server side

to check if it contains at least one capital letter, one number and one character?

...

I meant special characters like @#$%^&*

<!--- The pound sign(#) is a special Coldfusion symbol, and is
escaped with #. The dollar($), caret(^) and asterisk(*) are
special regex characters, and so are escaped with a backslash(\). --->


<cfset specialChars="[@##\$%\^&\*]">

<cfset testString="asdf@123.com">

<cfif REFind("[A-Z]"

...
Translate
LEGEND ,
Apr 13, 2010 Apr 13, 2010

Not sure what you mean by one character but, the function you want is REFind().

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2010 Apr 13, 2010

Thanks. I meant special characters like @#$%^&*

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 15, 2010 Apr 15, 2010

Someone more clever than me might be able to do it with a single rexex, but I'd do it with 3.

<cfif Refind(something for capital letters) gt 0

and Refind(something for numbers) gt 0

and Refind(something that's neither a number nor a letter) gt 0>

good

<cfelse>

bad

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 15, 2010 Apr 15, 2010

Thanks Dan. That is what

I have done but I'm struggiling with the regular expression to check for capital

letters, number and special characters in the submitted form field.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 15, 2010 Apr 15, 2010

To get the answer quickly, this might help.  http://www.regular-expressions.info/reference.html

To learn how to write regular expression patterns, this might help.  http://www.regular-expressions.info/tutorial.html

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 15, 2010 Apr 15, 2010

Thanks. I'm almost done with this. I have

not programmed in years and very rusty and things are coming back to me now bit by bit.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 15, 2010 Apr 15, 2010

andy99 wrote:

Sorry for the entry level question but how can I validate a text field server side

to check if it contains at least one capital letter, one number and one character?

...

I meant special characters like @#$%^&*

<!--- The pound sign(#) is a special Coldfusion symbol, and is
escaped with #. The dollar($), caret(^) and asterisk(*) are
special regex characters, and so are escaped with a backslash(\). --->


<cfset specialChars="[@##\$%\^&\*]">

<cfset testString="asdf@123.com">

<cfif REFind("[A-Z]",testString) GT 0 and REFind("[0-9]",testString) GT 0 and REFind(specialChars,testString) GT 0>
There's a match.
<cfelse>
There's no match.
</cfif>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 15, 2010 Apr 15, 2010

Thank you BKBK.

Cheers

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 15, 2010 Apr 15, 2010
LATEST

No thanks.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources