
May 31st, 2004, 09:11 PM
|
|
Contributing User
|
|
Join Date: Mar 2004
Location: Vancouver Island
Posts: 68
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.
|