> Please help I'm need to developing websites.
>
> How can I validate a group of fields in a form that only need to be
> required if one other field is required.
>
> I have some fields that are required and then other dependent
> fields. I need to be able to require a few other fields that are
> dependent on if another field has been populated.
>
> here is my code...
>
> function MM_validateForm() { //v4.0
>
> var
> i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
>
> for (i=0; i<(args.length-2); i+=3) { test=args[i+2];
val=MM_findObj
> (args[i]);
>
> if (val) { nm=val.name; if ((val=val.value)!="") {
>
> if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
>
> if (p<1 || p==(val.length-1)) errors+='- '+nm+' must
contain
> an e-mail address.\n';
>
> } else if (test!='R') {
>
> if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
>
> if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
>
> min=test.substring(8,p); max=test.substring(p+1);
>
> if (val<min || max<val) errors+='- '+nm+' must contain a
> number between '+min+' and '+max+'.\n';
>
> } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is
> required.\n'; }
>
>
> } if (errors) alert('The following error(s) occurred:\n'+errors);
>
> document.MM_returnValue = (errors == '');
>
> }
>
>
> ------------------------
>
> <input type="submit" name="Submit" value="Submit"
> onfiltered="MM_validateForm
>
('Dealer_Company_Name','','R','Dealer_Contact_Name','','R','DealerTele
>
phone','','R','Dealer_Review_Mgr_Name','','R','Registered_Company_Name
> ','','R','Company_Street_Address','','R','Company_City','','R','Comp
an
>
y_State','','R','Company_Zip','','R','Company_Country','','R','Company
>
_Telephone','','R','Billing_Contact_First_Name','','R','Billing_Contac
>
t_Last_Name','','R','Billing_Contact_Phone','','R','Billing_Contact_Em
>
ail','','RisEmail','Billing_Street_Address','','R','Billing_State','',
> 'R','Billing_City','','R','Billing_Country','','R','Billing_Zip_Code
',
> '','R');return document.MM_returnValue">
>
> How can I validate a group of fields in a form that only need to be
> required if one other field is required.
>
> I have some fields that are required and then other dependent
> fields. I need to be able to require a few other fields that are
> dependent on if another field has been populated.
>
> here is my code...
>
> function MM_validateForm() { //v4.0
>
> var
> i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
>
> for (i=0; i<(args.length-2); i+=3) { test=args[i+2];
val=MM_findObj
> (args[i]);
>
> if (val) { nm=val.name; if ((val=val.value)!="") {
>
> if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
>
> if (p<1 || p==(val.length-1)) errors+='- '+nm+' must
contain
> an e-mail address.\n';
>
> } else if (test!='R') {
>
> if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
>
> if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
>
> min=test.substring(8,p); max=test.substring(p+1);
>
> if (val<min || max<val) errors+='- '+nm+' must contain a
> number between '+min+' and '+max+'.\n';
>
> } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is
> required.\n'; }
>
>
> } if (errors) alert('The following error(s) occurred:\n'+errors);
>
> document.MM_returnValue = (errors == '');
>
> }
>
>
> ------------------------
>
> <input type="submit" name="Submit" value="Submit"
> onfiltered="MM_validateForm
>
('Dealer_Company_Name','','R','Dealer_Contact_Name','','R','DealerTele
>
phone','','R','Dealer_Review_Mgr_Name','','R','Registered_Company_Name
> ','','R','Company_Street_Address','','R','Company_City','','R','Comp
an
>
y_State','','R','Company_Zip','','R','Company_Country','','R','Company
>
_Telephone','','R','Billing_Contact_First_Name','','R','Billing_Contac
>
t_Last_Name','','R','Billing_Contact_Phone','','R','Billing_Contact_Em
>
ail','','RisEmail','Billing_Street_Address','','R','Billing_State','',
> 'R','Billing_City','','R','Billing_Country','','R','Billing_Zip_Code
',
> '','R');return document.MM_returnValue">
Comment