Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How I can validate a CFINPUT? 1

Status
Not open for further replies.

jjmew

Programmer
Aug 20, 2002
34
0
0
US
I need to know how to validate a CFINPUT. The value of the text needs to be between 1-30. What I can do to validate that input.

Please help me, I will really appreciate your help.
 
use javascript, in the form tag onsubmit=check_form()
in the function check_form check this (and other) field(s) for validation.
formname.inputname.value.length() returns the length of the string.
You can also set the max size of the field to 30.

Usefull? Vote! Erwin Oosterhoorn
Analyst Programmer,
Roller hockey'er, biker,
ice hockey player/fan.
 
actually, since the cf form tags generate javascript themselves, adding your own onsubmit javascript is a little tricky

luckily, the cfinput tag covers range validation

example:

<cfinput type = &quot;Text&quot; name = &quot;MyRange&quot; range = &quot;1,5&quot;
message = &quot;You must enter an integer from 1 to 5&quot;
validate = &quot;integer&quot; required = &quot;No&quot;>

see
rudy
 
You are right, didn't think far enough. Use a combination of form and cfform in my pages. Still, if the input only has to check if there are no more than 30 characters the maxlength=&quot;30&quot; should be the easiest implementation.
thanks for putting me right. ;-) Erwin Oosterhoorn
Analyst Programmer,
Roller hockey'er, biker,
ice hockey player/fan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top