Quantcast
Channel: Adobe Community : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 238792

How do I validate radio buttons with javascript upon submit.

$
0
0

I have written a script for submitting my form via this.maildoc.    It pulls the data entered into fields to dynamically generate the email subject, etc..  Because I am using this method of submission I must also script field validation.  I have written one script(Validation Script 1) that checks all text fields to see if they are empty.  If they are empty the user is prompted via app.alert to complete the form.  If they are not empty, the script moves on to Validation Script 2.  This script should check the radio buttons to see if any of the predetermined values are selected.  If they are it should move on to the submission script.  If they are not it should prompt the user via app.alert. 

 

"Validation Script 1" and the "Submission Script" work fine. My problem is with Validation Script 2.  I'm not sure how it's done, but I believe the choices for each button set should be listed in an array.  That is, the script should not be checking for all options to be selected, it should be checking for one of a set to be selected.  There are three radio button sets on my form. 

 

Thanks!

 

// Email Variables
var cToAddr = "me@myserver.com";
var cCCAddr = this.getField("RegistrantEmail").value;
var cSubLine = "Registration for our event in " + this.getField("EventCityState").value + " on " + this.getField("EventDate").value + " - " + this.getField("FullName").value;
var cBody = "Thank you for submitting your registration!  You may save the mail attachment for your own records.";// Validation Variables
var vEventDate = this.getField("EventDate").value;
var vEventCityState = this.getField("EventCityState").value;
var vCheckOne = this.getField("CheckOne").value;
var vFullName = this.getField("FullName").value;
var vAddress = this.getField("Address").value;
var vCity = this.getField("City").value;
var vState = this.getField("State").value;
var vZip = this.getField("Zip").value;
var vAreYouLicensed = this.getField("AreYouLicensed").value;
var vAreYouVT = this.getField("AreYouLicensedInVT").value;
var vTelephone = this.getField("Telephone").value; //Validation Script 1if ((vEventDate =="") || (vEventCityState =="") || (vFullName =="") || (vAddress =="") || (vCity =="") || (vState =="") || (vZip =="") || (vTelephone =="")){
app.alert("You must fill in all required fields before submitting.");
T.readonly = false;
F.readonly = false;}else//Validation Script 2if ((vCheckOne =="O.D.") || (vCheckOne =="M.D.") || (vCheckOne =="Other") || (vAreYouLicensed =="Yes") || (vAreYouLicensed =="No") || (vAreYouVT =="Yes") || (vAreYouVT =="No")){//Submission Script
this.mailDoc({    bUI: true,    cTo: cToAddr,    cCc: cCCAddr,    cSubject: cSubLine,    cMsg: cBody})
app.alert("NOTE: Clicking this button generates an email with your completed registration attached.  You must send this email to complete your registration.");}else{app.alert("Please check all required boxes before submitting.");
T.readonly = false;
F.readonly = false}

Viewing all articles
Browse latest Browse all 238792

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>