Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

Coldfusion Validation

Can someone show me how to do serverside validation for a field that can only have numbers and a field for phone numbers XXX-XXXX.

Do we use regular expressions?
0
champ_010
Asked:
champ_010
  • 2
1 Solution
 
champ_010Author Commented:
On second thought I should say that I did not use CFFORM.

My teacher didn't teach us about CFFORM--he just showed us some manual way of doing things like:

<cfparam name="problem" default="no">
<cfif isDefined("form.addBook")>
  <cfif form.bookTitle IS ''>
     <cfset problem='yes'>
     <cfset bookTitle_msg='*'>
</cfif>
 
etc. and in the end if problem="No" then the form validates.

I just realized that there's a whole other thing with cfform and cfinput.  Is this relatively new or why did he not teach us?  I guess I should learn cfform and do away with my manual way?

0
 
Renante EnteraCommented:
Hello champ_010!

I would suggest to do the server-side validation with the involvement of <cfform> tag and <cfinput>.

You can have your code into something like this :

<cfform name="form1" method="post">
Specify no. : <cfinput name="num" type="text" required="yes" validate="integer" message="Invalid number!"><br>
Telephone no . : <cfinput name="telno" type="text" required="yes" validate="telephone" message="Invalid telephone number!">
<input type="submit" value="Submit">
</cfform>

This will validate a field that can only have numbers and a field for phone numbers XXX-XXX-XXXX.

For tutorials, just browse to the following sites :
   <cfform> - http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-p38.htm#wp2433198
   <cfinput> - http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-p65.htm#wp1100379


Goodluck!
eNTRANCE2002 :-)
0
 
champ_010Author Commented:
O.k.--I should get around to learning this.  Am glad to see something like this.  I really enjoy the asp.net validation controls--looks like this cfform stuff is just as good.

Thanks
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now