Jump to content

Form Validating in Flash and sent to php file


ainoy31

Recommended Posts

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

Link to comment
Share on other sites

  • 7 months later...

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.