Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old March 9th, 2005, 12:32 PM
lmayer lmayer is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: USA
Posts: 225 lmayer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
One field validates the other

Morning,

I can't get the syntax just right. What I need it to do is say if one field is NOT NULL/Blank then make sure the other field is filled in.

This is what I have:
<script language="javascript">
if (!(formname.InternetAccess.value == "" && formname.VPEmail.value == ""))
{
alert("Please enter your VP's email address.");
return false;

}

return (true);
}
</script>

Any thoughts would be greatly appreciated

Thanks

Laura

Reply With Quote
  #2  
Old March 9th, 2005, 01:41 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: One field validates the other

try this

if ((formname.InternetAccess.value != "") && (formname.VPEmail.value == ""))

Reply With Quote
  #3  
Old March 9th, 2005, 01:46 PM
lmayer lmayer is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: USA
Posts: 225 lmayer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: One field validates the other

Hmmmm.

Still doesn't check. This is the whole thing:

<script language="javascript">
function Form_Validator(testform)
{
if ((testform.InternetAccess.value != "") && (testform.VPEmail.value == ""))
{
alert("Please enter your VP's email address.");
return false;
}

return (true);
}
</script>

<form name="testform" method="post" onSubmit="return Form_Validator(this)">

Reply With Quote
  #4  
Old March 9th, 2005, 02:42 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: One field validates the other

I just tested it and it worked fine. what does the rest of your form look like. I made my own to match because you did not include the code for yours.

Reply With Quote
  #5  
Old March 9th, 2005, 02:48 PM
lmayer lmayer is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: USA
Posts: 225 lmayer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: One field validates the other

This is the form part:

<form name="testform" method="post" onSubmit="return Form_Validator(this)">
<p><font face="Arial, Helvetica, sans-serif">VP email address:
<input name="VPEmail" type="text">
</font></p>
<p><font face="Arial, Helvetica, sans-serif">Internet Access:
<select name="InternetAccess" size="1">
<option selected> </option>
<option>Internet Access</option>
<option>Internet Access Enhanced</option>
<option>Intellitrader</option>
</select>
<input type="submit" name="Submit" value="Submit">
</font>
</form></p>

Reply With Quote
  #6  
Old March 9th, 2005, 02:55 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: One field validates the other

The problem is that your select box options do not have any values set. So either you need to add values to the options...

<option value="IA">Internet Access</option>

or if you dont want to do that, you can use the selectedIndex property of the select box to determine if a selection has been made...

if ((testform.InternetAccess.selectedIndex != 0) && (testform.VPEmail.value == ""))

Reply With Quote
  #7  
Old March 9th, 2005, 05:12 PM
lmayer lmayer is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: USA
Posts: 225 lmayer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: One field validates the other

Your brilliant Thanks so much...

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > One field validates the other


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT