Welcome to WebmasterWorld Guest from 54.145.166.96

Forum Moderators: open

Message Too Old, No Replies

Javascript syntax on form validator

   
5:57 pm on Nov 5, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a drop down list called 'profession'. If the proffession isn't on the list the visitor is asked to write it into a text box called 'other_profession'. If neither are selected I want my javascript form validator script to request it. I made the default value of the drop down list = x so if nothing is selected then I can check for a value of 'x' (don't know if thats the best way). Anyway... it doesn't work (as you can see my javascript is rather rough). Can anyone say what I'm missing? ;)
Extract from my javascript form validator script:

f = document.myForm;
if ((f.profession.value=="x") && (!(f.other_profession.value))) {
{ message += "Select your profession.\n";
submitOK="False"; }

6:03 pm on Nov 5, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ooops!

Just spotted the extra '{'
when reading my post.

gsx

6:03 pm on Nov 5, 2002 (gmt 0)

10+ Year Member



(!(f.other_profession.value))

is that valid?

I would write it as (f.other_profession.value == ""). I think you are stating that if other_profession has no value - but it does have a value - a null value or "".

 

Featured Threads

Hot Threads This Week

Hot Threads This Month