Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Validating Radio Buttons and List Boxes

Status
Not open for further replies.

voice3

Programmer
Nov 3, 2002
8
GB
Hi

I am using Flash M2004 Pro to build a contact form using the new components. The problem is that when it comes to validating the form it work with "email.text" and "question.text" (which are text fields), but I can not get it to work with radio buttons or list boxes.


myButtonListener = new Object();
myButtonListener.click = function()

{
var selectedRadioButton = gender.selection;
var theSelectedItem = age.selectedItem;

if(email.text == ""){
var Alert = mx.controls.Alert;
Alert.show("Please enter your emaill address.");
}else if(question.text == ""){
var Alert = mx.controls.Alert;
Alert.show("Please enter your question.");
}else if (selectedRadioButton.label ""){
var Alert = mx.controls.Alert;
Alert.show("Please choose your gender.");
}else if (theSelectedItem.label == ""){
var Alert = mx.controls.Alert;
Alert.show("Please choose your age.");
}else{
myData = new LoadVars();
myRequest = new LoadVars();
myRequest.onLoad = function(message) {
trace(message);

};


//dataholder
myData.email = email.text;
myData.question = question.text;
myData.gender = selectedRadioButton.label;
myData.age = theSelectedItem.label;
myData.sendAndLoad("mailer.php", myRequest, "POST");
gotoAndPlay("submitted");
};
};

submitBtn.addEventListener("click", myButtonListener);

Thanks in advance
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top