Link to home
Start Free TrialLog in
Avatar of phillystyle123
phillystyle123Flag for United States of America

asked on

re: multiple variables in simple form validation script

I've got 2 text fields -

1. attorney_name
2. attorney_phoneNumber

i need both to be filled out if my radio button:

attorney_representation - Yes

is checked.

i have a working script for 1 of the fields (attorney_name) but i need to add the other (attorney_phoneNumber)


function getRadialValue(strFieldName){
    var objFormField = document.forms[0].elements[strFieldName]
    intControlLength = objFormField.length
    for (i=0;i<intControlLength;i++){
         if(objFormField[i].checked){
                   strValue = objFormField[i].value;
                   return strValue;
         }
    }    
}
function validate(theForm){
      if(getRadialValue('attorney_representation')=='Yes'){
            if(theForm.attorney_name.value==''){
                  alert('Please enter Attorney Name');
            return false;
            }
      }
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of DerkArts
DerkArts
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of phillystyle123

ASKER

DerkArts - will you accept my proposal for marriage? ;-)
 thanks so much - i've been working on this way too long today - much appreciated