Hello all,
I am building an form in an AS3 swf which I’d like to validate and send form feild data to an asp server side file (order.asp) which will send the info via email. The swf will validate the data, but not send the data to asp.
I have a test form working in html to validate the asp, but I need to have it work from the AS3 swf. The code that I am using is posted below. Any help would be greatly appreciated!
stop();
import flash.events.*;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
// ----------------------------------------------------------------
var variables:URLVariables = new URLVariables();
var varSend:URLRequest = new URLRequest(“order.asp”);
var varLoader:URLLoader = new URLLoader;
varSend.method = URLRequestMethod.POST;
varSend.data = variables;
status_txt.text = “”;
submit_btn.addEventListener(MouseEvent.CLICK, ValidateAndSend);
function ValidateAndSend(event:MouseEvent):void{
//validate form fields
if(!yn1.length) {
status_txt.text= “Please answer .1”;
} else if(!yn2.length) {
status_txt.text = “Please answer .2”;
} else if(!yn3.length) {
status_txt.text = “Please answer .3”;
} else if(!yn4.length) {
status_txt.htmlText = “Please answer .4”;
} else if(!yn5.length) {
status_txt.text = “Please answer .5”;
} else if(!yn6.length) {
status_txt.text = “Please answer .6”;
} else if(!yn7.length) {
status_txt.text = “Please answer .7”;
} else if(!yn8.length) {
status_txt.text = “Please answer .8”;
} else if(!dm.length) {
status_txt.text = “Please enter the month of your birth”;
} else if(!dd.length) {
status_txt.text = “Please enter the day of your birth”;
} else if(!dy.length) {
status_txt.text = “Please enter the year of your birth”;
} else if(!acc_name.length) {
status_txt.text = “Please enter the name as it appears on your account.”;
} else if(!phone.length) {
status_txt.text = “Please enter your phone number”;
} else if(!address1.length) {
status_txt.text = “Please enter your mailing address”;
} else if(!state1.length) {
status_txt.text = “Please enter your state”;
} else if(!zip.length) {
status_txt.text = “Please enter your zip code”;
} else if(!validateEmail(email.text)) {
status_txt.text = “Please enter a VALID email address”;
} else if(!bank_name.length) {
status_txt.text = “Please enter the name of your bank.”;
} else if(!bank_address.length) {
status_txt.text = “Please enter the address of your bank”;
} else if(!check_number.length) {
status_txt.text = “Please enter a number”;
} else if(!bank_state.length) {
status_txt.text = “Please enter in what state your bank is located”;
} else if(!bank_zip.length) {
status_txt.text = “Please enter the zip code for your bank”;
} else if(!routing_number.length) {
status_txt.text = “Please enter your routing number (located in the bottom left of your check)”;
} else if(!account_number.length) {
status_txt.text = “Please enter your bank account number”;
} else {
status_txt.text = "Your Order has been processed, you will be contacted for vailidation purposes… " + acc_name.text + “, your order has been sent!”;
gotoAndStop(2);
}
}
function validateEmail(str:String):Boolean {
var pattern:RegExp = /(\w|[_.-])+@((\w|-)+.)+\w{2,4}+/;
var result:Object = pattern.exec(str);
if(result == null) {
return false;
}
return true;
}