Reputation: 139
I am new to this Adobe flex development.Right now I am working on the application and in my mxml form I have to place 2 fields.
one is Radio button(option (yes ,no) )and another one is text box(name), and the requirement is:
when the user selects yes then the name field should enable otherwise it should be disable. The validation rules are:
if the user selects yes and he would not enter any value(textbox is empty) then we should display error message that "value is required"
if the user selects no and the text filed has some value then first he has to delete the contents in the textfiled then only select 'no'
.
someone please help me and give me some code sample.That would be great help for me.
Upvotes: 1
Views: 1188
Reputation: 1884
put this code in your MXML
application and run..
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="567" height="206" minWidth="955" minHeight="600" initialize="application1_initializeHandler(event)">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
protected function application1_initializeHandler(event:FlexEvent):void
{
}
protected function rd1_clickHandler(event:MouseEvent):void
{
if(!t1.enabled)
{
t1.enabled=true;
}
else if(t1.text=="" && t1.enabled)
{
Alert.show("Value is required in text box");
}
else
t1.enabled=true;
}
protected function rd2_clickHandler(event:MouseEvent):void
{
t1.text=null
t1.enabled =false;
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:TextInput x="132" y="41" id="t1"/>
<s:RadioButton x="162" y="91" label="Yes" id="rd1" groupName="select" click="rd1_clickHandler(event)"/>
<s:RadioButton x="211" y="91" label="No" id="rd2" groupName="select" click="rd2_clickHandler(event)" />
<s:Label x="79" y="45" text="Name"/>
</s:Application>
Upvotes: 2
Reputation: 4340
Create a custom mxml control based on TitleWindow and us PopupManager to show it on display.
Upvotes: 0