HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

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 ASP Free Forums Sponsor:
  #1  
Old May 31st, 2004, 09:11 PM
ballscribble ballscribble is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Vancouver Island
Posts: 68 ballscribble User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 30 m 54 sec
Reputation Power: 5
javascript validate that one of two fields has a value

Hello,

Trying to use JavaScript to validate that at least one of two fields has a value in it when the form is submitted. The code provided currently only works if the first value (U_EMAIL) has a value in it. Any suggestions to correct this?

Code:
  
function IsEmpty(atextfield, btextfield) {
   if ((atextfield.value.length==0) ||
   (atextfield.value==null)) {
   ((btextfield.value.length==0) ||
   (btextfield.value==null))
	  return true;
   }
   else { return false; }
} 
function chkcontact()
{
   if(IsEmpty(form2.U_EMAIL, form2.U_PHONE)) 
   { 
   alert('You have not entered a contact method!')
   document.form2.agreecheck1.checked = false;
  return false; 
   } 
 
agreesubmit();
return true;
 
} 


Thanks for your help.

Reply With Quote
  #2  
Old June 4th, 2004, 02:44 AM
Yeruhn's Avatar
Yeruhn Yeruhn is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: Netherlands
Posts: 428 Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level)Yeruhn User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 16 h 35 m 27 sec
Reputation Power: 10
Change IsEmpty() to:
Code:
  
function IsEmpty(atextfield, btextfield) {
   if ((atextfield.value.length==0) || (atextfield.value==null) ||
      (btextfield.value.length==0) || (btextfield.value==null))
	  return true;
   }
   else { return false; }
}

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > javascript validate that one of two fields has a value


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 5 hosted by Hostway