RE: Silly Validation Question...

2001-05-30 Thread Dan G. Switzer, II

Brandon,

Check out qForms:
http://www.pengoworks.com/qForms/

It has all sorts of really easy to use validation methods. For example, to
make sure they select a state, you could just do:

obj.fieldName.validateState();

or to simply check that the value was not blank:
obj.fieldName.validateNotEmpty();

or you could expand the above and provide a custom error message:
obj.fieldName.validateNotEmpty("You must select a state from the drop down
list.");

That's it! This is just the tip of the iceberg as well, it's very, very
flexible and very easy to use.

-Dan

> -Original Message-
> From: Brandon Wood [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 29, 2001 5:13 PM
> To: CF-Talk
> Subject: Silly Validation Question...
>
>
> Hey,
>
> Does anyone have a good script or method of making a select box contain a
> value other than ""?
>
> I am working on a state drop-down in which the first selection is "Pick
> State" with a value of "".
>
> What I want to happen is for a javascript screen to pop up (or something
> like that--you know the usual CFFORM javascript validation) if a
> user tries
> to submit the form without choosing a state that has a value.  I
> have seenm
> this used many times and even with CFSELECT form fields, but I am
> having the
> worst time trying to implement this.
>
> I want to populate the CFSELECT with a query from a State_Table but do not
> want to store a state with a value of "" as not to populate a state field
> with NULL answer.
>
> Is there an OnError or someother Javanscript function that could make sure
> that a value other than "" was chosen and that the error message could be
> configurable.  I know that this is so CF 101, but I have never had to do
> this and am pulling my hair out in anger.
>
> Thanks a ton,
> BW
>
>
>
~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



Re: Silly Validation Question...

2001-05-30 Thread G

Make your "submit" button call a javascript function that: 1) checks the
value of the select box and 2) submits if not NULL, otherwise, displays an
error message.

Something like this:


function CheckForNull( )
{
if (document.FormName.selectBox.value == "")
alert ("Please select a state")
else
document.FormName.submit()
}


Then your button:



(I haven't tested the syntax of the code, remember JS is case sensitive)

HTH
Brian
- Original Message -
From: "Brandon Wood" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Tuesday, May 29, 2001 4:13 PM
Subject: Silly Validation Question...


> Hey,
>
> Does anyone have a good script or method of making a select box contain a
> value other than ""?
>
> I am working on a state drop-down in which the first selection is "Pick
> State" with a value of "".
>
> What I want to happen is for a javascript screen to pop up (or something
> like that--you know the usual CFFORM javascript validation) if a user
tries
> to submit the form without choosing a state that has a value.  I have
seenm
> this used many times and even with CFSELECT form fields, but I am having
the
> worst time trying to implement this.
>
> I want to populate the CFSELECT with a query from a State_Table but do not
> want to store a state with a value of "" as not to populate a state field
> with NULL answer.
>
> Is there an OnError or someother Javanscript function that could make sure
> that a value other than "" was chosen and that the error message could be
> configurable.  I know that this is so CF 101, but I have never had to do
> this and am pulling my hair out in anger.
>
> Thanks a ton,
> BW
>
>
>
~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



Re: Silly Validation Question...

2001-05-29 Thread Brandon Wood

Think I figured it out the first part using the cf_field_validation tag.
Pretty neat!

The only problem is that I want to call two javascript functions from the
same onsubmit call--due to the fact that I have two separate loops running
in order to serve up two parts of the dynamic form.

What's the proper format to use when calling multiple javascript functions
from the same form?

This doesn't seem to work:





It does work however with the first set of "state" javascript checksbut
the "state_2" checks do not get executed.

This is so dumb, but what can I call to get both "state" and "state_2"
javascript functions to get executed once the user clicks the submit button?

Thanks a ton,
BW


- Original Message -
From: "Mark Warrick" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Tuesday, May 29, 2001 7:15 PM
Subject: RE: Silly Validation Question...


> Brandon,
>
> The solution to the problem is to NOT use CFFORM for validation.  Use
> roll-your-own JavaScripts instead.  You'll have far greater flexibility.
>
> Here's an example of how I was able to make sure a state was selected in a
> form:
>
>
> -snip---
> <!--
> function validate(form) {
>   if (form.state_code.selectedIndex == 0) {
> alert('Please select a state.');
> return false;
>   }
>   return true;
> }
> //-->
>
>
> 
>
> 
>
> 
> #state_code#
> 
>
> 
>
> 
> SELECT  STATE_CODE, STATE_NAME
> FROM STATES
> ORDER BY  STATE_NAME
> 
>
> 
> 
> 
> Select a State:
> 
>
> 
> #state_name#
> 
>
> 
> 
> 
>
> snip-
>
> 
> Mark Warrick - Fusioneers.com
> Email: [EMAIL PROTECTED]
> Phone: 714-547-5386
> http://www.fusioneers.com
> http://www.warrick.net
> 
>
> > -Original Message-
> > From: Brandon Wood [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, May 29, 2001 2:13 PM
> > To: CF-Talk
> > Subject: Silly Validation Question...
> >
> >
> > Hey,
> >
> > Does anyone have a good script or method of making a select box contain
a
> > value other than ""?
> >
> > I am working on a state drop-down in which the first selection is "Pick
> > State" with a value of "".
> >
> > What I want to happen is for a javascript screen to pop up (or something
> > like that--you know the usual CFFORM javascript validation) if a
> > user tries
> > to submit the form without choosing a state that has a value.  I
> > have seenm
> > this used many times and even with CFSELECT form fields, but I am
> > having the
> > worst time trying to implement this.
> >
> > I want to populate the CFSELECT with a query from a State_Table but do
not
> > want to store a state with a value of "" as not to populate a state
field
> > with NULL answer.
> >
> > Is there an OnError or someother Javanscript function that could make
sure
> > that a value other than "" was chosen and that the error message could
be
> > configurable.  I know that this is so CF 101, but I have never had to do
> > this and am pulling my hair out in anger.
> >
> > Thanks a ton,
> > BW
> >
> >
> >
>
~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



Re: Silly Validation Question...

2001-05-29 Thread Brandon Wood

Hmm...

Tried just about every suggestion, and nothing seems to be popping up as a
warning...the form just submits anyway.

I have written a dynamic form loops through a table and gets all of the
questions that appear for the form, then loops through various question
types to see what type of question it is.  Then when a question of type
"state" is called, a dynamic drop down is generated with a unique question
id and a list of states to choose from.

The code I am using follows--which doesn't seem to work:






 SELECT * FROM State_Table
 ORDER BY State_ID



 
 if (document.addcase.qu_#sec_info.cqid#.value == "void"){
 alert("Pick a state!");
 }
 





 SELECT STATE
 
  #state#
 

   



 



I can't seem to get the message to pop up, and it is driving me crazy.  Am I
putting the javascript in the wrong place.  It seems as though, since the
form is displayed on the fly that I need to keep the javascript near the
loop item, so that the dynamic form field name sits together with the
dynamic field.  I just can't get the javascript to notice if I have or
haven't chosen the "void" value.  The form just submits regardless.

Thanks again for all of the suggestions, so far.

Cheers,
Brandon


- Original Message -
From: "David Baskin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, May 29, 2001 6:17 PM
Subject: RE: Silly Validation Question...


> Brandon, put your "pick a state" select option before your cfoutput on the
> state query. then, on submit of the form, do a check to see if the user
has
> not selected a state. i use a value of "void" in my boxes and then just do
a
> simple javascript check to see if the value of the select box is void. if
> so, throw an error. HTH.
>
> d
>
> example:
>
> cf:
> select name="state" size="1"
> option value="void" Select a State
> cfoutput query="states"
> option value="state_cd" #state_cd#
> /cfoutput
>
> javascript:
> if (document.yourformname.state.value == "void"){
> alert("Pick a state!");
> }
>
>
> -Original Message-
> From: Brandon Wood [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 29, 2001 2:13 PM
> To: CF-Talk
> Subject: Silly Validation Question...
>
>
> Hey,
>
> Does anyone have a good script or method of making a select box contain a
> value other than ""?
>
> I am working on a state drop-down in which the first selection is "Pick
> State" with a value of "".
>
> What I want to happen is for a javascript screen to pop up (or something
> like that--you know the usual CFFORM javascript validation) if a user
tries
> to submit the form without choosing a state that has a value.  I have
seenm
> this used many times and even with CFSELECT form fields, but I am having
the
> worst time trying to implement this.
>
> I want to populate the CFSELECT with a query from a State_Table but do not
> want to store a state with a value of "" as not to populate a state field
> with NULL answer.
>
> Is there an OnError or someother Javanscript function that could make sure
> that a value other than "" was chosen and that the error message could be
> configurable.  I know that this is so CF 101, but I have never had to do
> this and am pulling my hair out in anger.
>
> Thanks a ton,
> BW
>
>
>
~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Silly Validation Question...

2001-05-29 Thread Mark Warrick

Brandon,

The solution to the problem is to NOT use CFFORM for validation.  Use
roll-your-own JavaScripts instead.  You'll have far greater flexibility.

Here's an example of how I was able to make sure a state was selected in a
form:


-snip---








#state_code#





SELECT  STATE_CODE, STATE_NAME
FROM STATES
ORDER BY  STATE_NAME





Select a State:



#state_name#






snip-


Mark Warrick - Fusioneers.com
Email: [EMAIL PROTECTED]
Phone: 714-547-5386
http://www.fusioneers.com
http://www.warrick.net


> -Original Message-
> From: Brandon Wood [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 29, 2001 2:13 PM
> To: CF-Talk
> Subject: Silly Validation Question...
>
>
> Hey,
>
> Does anyone have a good script or method of making a select box contain a
> value other than ""?
>
> I am working on a state drop-down in which the first selection is "Pick
> State" with a value of "".
>
> What I want to happen is for a javascript screen to pop up (or something
> like that--you know the usual CFFORM javascript validation) if a
> user tries
> to submit the form without choosing a state that has a value.  I
> have seenm
> this used many times and even with CFSELECT form fields, but I am
> having the
> worst time trying to implement this.
>
> I want to populate the CFSELECT with a query from a State_Table but do not
> want to store a state with a value of "" as not to populate a state field
> with NULL answer.
>
> Is there an OnError or someother Javanscript function that could make sure
> that a value other than "" was chosen and that the error message could be
> configurable.  I know that this is so CF 101, but I have never had to do
> this and am pulling my hair out in anger.
>
> Thanks a ton,
> BW
>
>
>
~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists



RE: Silly Validation Question...

2001-05-29 Thread Bryan Love

it just takes some getting used to:

1. write the JS function

function checkForm(theForm){
var selInd = theForm.state.selectedIndex;
var boxVal = theForm.state.options[selInd].value;

if( boxVal != "" )
return true;

alert("You must select a state");
return false;

}

2.  Put ONSUBMIT in the form tag





Bryan Love ACP
Internet Application Developer
[EMAIL PROTECTED]



-Original Message-
From: Brandon Wood [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 29, 2001 2:13 PM
To: CF-Talk
Subject: Silly Validation Question...


Hey,

Does anyone have a good script or method of making a select box contain a
value other than ""?

I am working on a state drop-down in which the first selection is "Pick
State" with a value of "".

What I want to happen is for a javascript screen to pop up (or something
like that--you know the usual CFFORM javascript validation) if a user tries
to submit the form without choosing a state that has a value.  I have seenm
this used many times and even with CFSELECT form fields, but I am having the
worst time trying to implement this.

I want to populate the CFSELECT with a query from a State_Table but do not
want to store a state with a value of "" as not to populate a state field
with NULL answer.

Is there an OnError or someother Javanscript function that could make sure
that a value other than "" was chosen and that the error message could be
configurable.  I know that this is so CF 101, but I have never had to do
this and am pulling my hair out in anger.

Thanks a ton,
BW
~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists