ainoy31 Posted June 20, 2007 Share Posted June 20, 2007 Can anyone help me with validating a form within a flash file and then the variables get pass to another php form where this process the given data and then emails to my client? Hope that is not too confusing. much appreciation. AM Quote Link to comment Share on other sites More sharing options...
koolaid Posted February 11, 2008 Share Posted February 11, 2008 The form validation is easy in flash. I wrote this one and it is pretty thorough. First i create an array that i will reffer to later. This seems to be unecessary, but it is cool because you can later add as many fields to the array that you want verified. you put additional fields to verify here: (checkInputs([form.name1, form.email1, form.body_txt1])). After that i begin the function that occurs when the submit button is released. I start by verifying that there is an @ sign and it's relationship to the "." Now this wont stop someone from putting a fake email that appears valid (fake_email@myballs.com), but it will keep them from just putting "blahblah". If that passes it goes to my checkInputs array where you add every field that is required. If everyone of those fields has content it sends the variables to the email.php doc. If the variables pass successfully it sends my flash piece to a thank you screen. There are much simpler methods, but they have no verification. stop(); function checkInputs(arr:Array){ for (var i=0;i < arr.length; i++){ if(arr[i].text == ""){ return false; } } return true; } submit_btn.onRelease = function() { ////this PORTION validates email addrress it checks the text field VIA VARIABLE NAME------------ indexOfAt = form.email.text.indexOf("@"); lastIndexOfDot = form.email.text.lastIndexOf("."); if (!form.email.length || form.email.indexOf("@") == -1 || form.email.indexOf(".") == -1) { required1.text = "PLEASE ENTER A VALID EMAIL ADDRESS"; }else{ required1.text="VERIFYING..."; trace("step one passed... running step 2"); ////checks all the other required fields VIA INSTANCE NAMES------------- if (checkInputs([form.name1, form.email1, form.body_txt1])){ // send variables in form movieclip (the textfields) required1.text= ("SENDING...."); form.loadVariables("email.php", "POST"); form.onData = allgood; trace("all info verified sending message"); }else{ required1.text= ("PLEASE FILL OUT ALL REQUIRED FIELDS"); trace("made it to check inputs then failed"); } } } function allgood() { gotoAndStop("contacted"); required1.text= ("MESSAGE SENT SUCCESSFULY!"); trace("completely successful"); } For the php do a search for flash email for and you will get 10 good tutorials right away. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.