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

Form Page Data Validation?

New Here ,
Apr 26, 2007 Apr 26, 2007

Copy link to clipboard

Copied

I use ColdFusion's built-in server-side data validation alot:

input type="hidden" name="address_required" value="The Address field is required."

I love the fact that it goes on the page that contains the form fields, rather than the page that processes the form. That is, if page1.cfm has the form, and page2.cfm has a query that writes the Address to a database, I can put the validation on page1.cfm

Is there any way possible to write custom validation code that can go on the form page, rather than the processing page? By "custom validation", I mean something CF doesn't natively handle. Something like verifying that if the "Other" radio button is selected, they also filled in the "Specify" textbox.

Any thoughts?

Thanks.
TOPICS
Advanced techniques

Views

931

Translate

Translate

Report

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 26, 2007 Apr 26, 2007

Copy link to clipboard

Copied

you will have to write your own javascript functions. that is in fact
what cf does, too, behind the scenes...

i suggest you review your view on server-side validation, as it is a lot
more robust and will function even if your user has javascript disabled.
client-side form validation will be omitted if your users have js
disabled, and you may end up with all sorts of wrong data in your tables...
--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

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 26, 2007 Apr 26, 2007

Copy link to clipboard

Copied

I'm not looking for client-side validation. I want server-side.

Votes

Translate

Translate

Report

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 26, 2007 Apr 26, 2007

Copy link to clipboard

Copied

what you are actually employing with the name="something_required" form
fieldnames is only client-side. CF re-writes this code into javascript
whaen it processes the page request. it is NOT server-side at all.

check your page's source and you will see the javascript CF has put into it.

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

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
Advocate ,
Apr 26, 2007 Apr 26, 2007

Copy link to clipboard

Copied

quote:

Originally posted by: Newsgroup User
what you are actually employing with the name="something_required" form
fieldnames is only client-side. CF re-writes this code into javascript
whaen it processes the page request. it is NOT server-side at all.

check your page's source and you will see the javascript CF has put into it.

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com



With reference to the documentation (Line number 1)... It is actually a SERVER side validation routine which is not done in Client Side like you said...

Votes

Translate

Translate

Report

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 26, 2007 Apr 26, 2007

Copy link to clipboard

Copied

quote:

Originally posted by: Newsgroup User
what you are actually employing with the name="something_required" form
fieldnames is only client-side. CF re-writes this code into javascript
whaen it processes the page request. it is NOT server-side at all.

check your page's source and you will see the javascript CF has put into it.


The CFform tags generate Javascript. The use of the hidden input tag performs server-side validation.

Votes

Translate

Translate

Report

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 30, 2007 Apr 30, 2007

Copy link to clipboard

Copied

Is there any way possible to write custom validation code that can go
on the form page, rather than the processing page?


Yes. The customary way to do it is to submit the form to its own page.

Votes

Translate

Translate

Report

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 27, 2007 Apr 27, 2007

Copy link to clipboard

Copied

This is how I do it:

http://www.fordwebs.com/cfform.cfm

--
Ken Ford
Adobe Community Expert
Fordwebs, LLC
http://www.fordwebs.com


"Heavy_Doody" <webforumsuser@macromedia.com> wrote in message news:f0rmcb$me3$1@forums.macromedia.com...
>I use ColdFusion's built-in server-side data validation alot:
>
> input type="hidden" name="address_required" value="The Address field is
> required."

>
> I love the fact that it goes on the page that contains the form fields, rather
> than the page that processes the form. That is, if page1.cfm has the form, and
> page2.cfm has a query that writes the Address to a database, I can put the
> validation on page1.cfm
>
> Is there any way possible to write custom validation code that can go on the
> form page, rather than the processing page? By "custom validation", I mean
> something CF doesn't natively handle. Something like verifying that if the
> "Other" radio button is selected, they also filled in the "Specify" checkbox.
>
> Any thoughts?
>
> Thanks.
>

Votes

Translate

Translate

Report

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 27, 2007 Apr 27, 2007

Copy link to clipboard

Copied

Okay, so there's another "no".

Votes

Translate

Translate

Report

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 27, 2007 Apr 27, 2007

Copy link to clipboard

Copied


oops... you are right, as is Daverms. server-side of course. my bad.
the lack of sleep and the bout of flu must be affecting me more than i
thought...

--
Azadi Saryev
Sabai-dee.com
Vientiane, Laos
http://www.sabai-dee.com

Votes

Translate

Translate

Report

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
Advocate ,
Apr 30, 2007 Apr 30, 2007

Copy link to clipboard

Copied

Also leaving the value that you passed for the action attribute as blank will make the form to be submitted to its own page.

Votes

Translate

Translate

Report

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 ,
May 01, 2007 May 01, 2007

Copy link to clipboard

Copied

Unfortunately, that isn't an option in this particular case.

Votes

Translate

Translate

Report

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 ,
May 01, 2007 May 01, 2007

Copy link to clipboard

Copied

LATEST
> Unfortunately, that isn't an option in this particular case.
Do you mean submitting the form page to itself isn't an option?

Votes

Translate

Translate

Report

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
Documentation