Menu

[r114]: / cairngorm3 / trunk / libraries / ValidationTest / src / Sample2.mxml  Maximize  Restore  History

Download this file

55 lines (42 with data), 1.8 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
creationComplete="handleCreationComplete()">
<mx:Script>
<![CDATA[
import mx.validators.StringValidator;
import com.adobe.cairngorm.validation.ValidatorGroup;
[Bindable]
private var validatorGroup : ValidatorGroup =
new ValidatorGroup();
private var firstnameValidator : StringValidator =
new StringValidator();
private var lastnameValidator : StringValidator =
new StringValidator();
private function handleCreationComplete() : void
{
firstnameValidator.required = true;
firstnameValidator.source = firstnameInput;
firstnameValidator.property = "text";
lastnameValidator.required = true;
lastnameValidator.source = lastnameInput;
lastnameValidator.property = "text";
validatorGroup.addValidator( firstnameValidator );
validatorGroup.addValidator( lastnameValidator );
}
]]>
</mx:Script>
<mx:Form>
<mx:FormItem label="firstname">
<mx:TextInput id="firstnameInput" text=""/>
</mx:FormItem>
<mx:FormItem label="lastname">
<mx:TextInput id="lastnameInput" text="blabla"/>
</mx:FormItem>
<mx:FormItem label="FORM VALIDITY" backgroundColor="{ validatorGroup.isValid ? 0xFF00 : 0xFF0000 }">
<mx:Label text="{ validatorGroup.isValid }" />
</mx:FormItem>
</mx:Form>
<mx:Button label="force validation" click="validatorGroup.validate()" />
</mx:Application>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.