A simple Flex Builder contact form
Ok here is my simple flex builder contact form. It will validate fields then post form data to a backend page for processing. This Flex Builder Form does not use the httpservice to retrieve information its just a simple post form that keeps the bots from filling out the form on a standard web site
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:validators="validators.*" applicationComplete="validator()" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="480" height="500" backgroundGradientColors="[#ffffff, #ffffff]">
<mx:Script>
<![CDATA[
private function validator():void {
submitButton.enabled = Validator.validateAll(
[requireName, requirePhone, validateEmail]).length == 0;
}
private function submit():void {
var args:URLVariables = new URLVariables();
args.oName = oName.text;
args.oEmail = oEmail.text;
args.oPhone = oPhone.text;
args.oMessage = oMessage.text;
var url:URLRequest = new URLRequest("http://www.cdrepro.com/mailer.cfm");
url.method = "POST";
url.data = args;
navigateToURL(url,"_self");
}
]]>
</mx:Script>
<mx:Form name="mailer" x="0" y="0" width="470" height="481">
<mx:FormItem label="Name:" required="true">
<mx:TextInput name="oName" id="oName" width="256" change="validator()"/>
</mx:FormItem>
<mx:FormItem label="Email:" required="true">
<mx:TextInput name="oEmail" id="oEmail" width="255" change="validator()"/>
</mx:FormItem>
<mx:FormItem label="Phone:" required="true">
<mx:TextInput name="oPhone" id="oPhone" width="255" change="validator()"/>
</mx:FormItem>
<mx:FormItem label="Message:">
<mx:TextArea width="333" name="oMessage" id="oMessage" height="317"/>
</mx:FormItem>
<mx:FormItem>
<mx:Button id="submitButton" label="Submit Request" click="submit()"/>
</mx:FormItem>
</mx:Form>
<mx:Validator id="requireName" required="true" source="{oName}" property="text" />
<mx:Validator id="requirePhone" required="true" source="{oPhone}" property="text" />
<mx:EmailValidator id="validateEmail" required="true" source="{oEmail}" property="text" />
</mx:Application>
Wiredwizard
Memphis, TN
Comments