[img]http://dl.iteye.com/upload/attachment/559697/2cd2daa9-cb50-325a-b197-ac9df6c54e88.jpg[/img]
在正则表达式中,含有大括号时,验证不通过,需自定义一个字符串值为正则表达式的内容。
验证通过时才执行操作。
valid="keyPhone_A_Button_clickHandler(event)" 为验证通过时触发的事件,
当然也有验证不通过时触发的事件了。
text="@{keyPhoneVO.phoneNumber_Text}" 是进行数据双向绑定的,测试时可以先去掉。
mxml文件:
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<mx:RegExpValidator source="{phoneNumber_Text}"
property="text"
expression="{ValidateVO.phoneValidat}"
trigger="{keyPhone_A_Button}"
valid="keyPhone_A_Button_clickHandler(event)"
triggerEvent="click"
noMatchError="请输入正确的手机号"
required="true"
requiredFieldError="新增时必须输入手机号"/>
</fx:Declarations>
<s:TextInput id="phoneNumber_Text" x="66" y="35" contentBackgroundColor="#FFFDFD"
text="@{keyPhoneVO.phoneNumber_Text}"/>
在ValidateVO.
as文件中,定义正则表达式。直接在expression中写正则表达式时,编译无法识别,按照官网介绍的方法,我们还是自己定义一个字符串好了。
// 电信手机号验证表达式
public static var phoneValidat:String = "^1(3[3]|5[3]|8[09])\\d{8}$";
在正则表达式中,含有大括号时,验证不通过,需自定义一个字符串值为正则表达式的内容。
验证通过时才执行操作。
valid="keyPhone_A_Button_clickHandler(event)" 为验证通过时触发的事件,
当然也有验证不通过时触发的事件了。
text="@{keyPhoneVO.phoneNumber_Text}" 是进行数据双向绑定的,测试时可以先去掉。
mxml文件:
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<mx:RegExpValidator source="{phoneNumber_Text}"
property="text"
expression="{ValidateVO.phoneValidat}"
trigger="{keyPhone_A_Button}"
valid="keyPhone_A_Button_clickHandler(event)"
triggerEvent="click"
noMatchError="请输入正确的手机号"
required="true"
requiredFieldError="新增时必须输入手机号"/>
</fx:Declarations>
<s:TextInput id="phoneNumber_Text" x="66" y="35" contentBackgroundColor="#FFFDFD"
text="@{keyPhoneVO.phoneNumber_Text}"/>
在ValidateVO.
as文件中,定义正则表达式。直接在expression中写正则表达式时,编译无法识别,按照官网介绍的方法,我们还是自己定义一个字符串好了。
// 电信手机号验证表达式
public static var phoneValidat:String = "^1(3[3]|5[3]|8[09])\\d{8}$";