> Is there a way within JavaScript to require a textbox to be filled out
> depending on whether or not a certain selection has been made in a
select
> box? IE: If the user checks "Unhappy", the "Tell me why" textbox field
> must be required.
>
>
> Here is a function that checks whether or not the field it is called
from
> is empty, but it check needs to be a DIFFERENT field:
> function emptyvalidation(entered, alertbox)
> {
> // Emptyfield-Validation by Henrik Petersen / NetKontoret
> // Explained at www.netkontoret.dk/jsforms.htm
> // Please do not remove the this line and the two lines above.
> with (entered)
> {
> if (value==null || value=="")
> {if (alertbox!="") {alert(alertbox);} return false;}
> else {return true;}
> }
> }
>
> any suggestions would be appreciated
>
> -liz
>
Something I did on my companies intranet site that sounds similar was to
have a text box with an attribute STYLE="display:none"
Then I had a select box that ran a function when the focus was lost. If
the selection was "a" then nothing happenned, but if it was "b" then it
changed the STYLE attribute of the text box to "display:block"
This meant that the text box was not visible until somebody chose
option "b".
You could have a similar thing whereby when focus was lost in your text
box you could check to see if it was null. If so then nothing would
change. If however somebody had input something into the text box the
STYLE attribute of the other text box would be changed and the text box
made visible.
Hope this helps you.
Phillip, England