homepage Welcome to WebmasterWorld Guest from 107.21.135.68
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Javascript syntax on form validator
kapow




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

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"; }

 

kapow




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

Ooops!

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

gsx




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

(!(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 "".

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved