Flex 一些数据的验证(邮箱,字符串,日期,年龄,性别)

1.邮件验证
<mx:EmailValidator
        id="emailV"
        source="{txtEmail}"
        property="text"
        invalidCharError="
非法字符"
        invalidDomainError="
非法域"
        invalidIPDomainError="
非法IP"
        missingAtSignError="
缺少@"
        missingPeriodInDomainError="
缺少域后缀"
        missingUsernameError="
缺少用户名"/>

2.
字符串长度验证
<mx:StringValidator source="{fname}" property="text"
        tooShortError="
字符串太短了,请输入最少4个字符. "
        tooLongError="
字符串太长了,请输入最长20个字符. "
        minLength="4" maxLength="20"
        trigger="{myButton}" triggerEvent="click"
        valid="Alert.show('
字符串格式正确!');"/>  

3.
日期验证
<mx:DateValidator source="{txtDate}" property="text"
        required="true" requiredFieldError="
请输入日期"
        allowedFormatChars="-" inputFormat="YYYY-MM-DD"
        trigger="{btnSubmit}" triggerEvent="click"
        valid="mx.controls.Alert.show('
验证成功');"
        invalid="mx.controls.Alert.show('
验证失败');"
        wrongDayError="
日输入错误"
        wrongMonthError="
月输入错误"
        wrongYearError="
年输入错误"
        wrongLengthError="
日期长度错误"
        invalidCharError="
日期分隔符错误"
        formatError="inputFormat
 配置错误"/>

4.
英文字母验证
 <mx:RegExpValidator id="regExpValidator" 
        source
="{txtInput}" property="text" 
        flags
="g,i" expression="^[a-z]+$" 
        valid
="handleResult(event)" invalid="handleResult(event)"
        trigger
="{btnSubmit}" triggerEvent="click"
        noMatchError
="
请输入正确的英文字母"
        required
="false"/>
5.年龄验证
<mx:NumberValidator id="ageV" source="{ageTI}" property="text"
    domain="int"
    minValue="6"
    maxValue="100"
    lowerThanMinError="
年龄过小!"
    exceedsMaxError="
年龄过大!"
    integerError="
年龄必须是整数!"
    invalidCharError='
输入了非数字字符!'
    requiredFieldError="
必须输入年龄!"
    trigger="{btn}" triggerEvent="click"/>

6.
性别验证
<mx:Validator id="sexV" source="{sexRBG}" property="selectedValue"
    requiredFieldError="
必须选择性别!"
    trigger="{btn}" triggerEvent="click"
    listener="{maleRB}"/>
   <mx:FormItem label="
性别:" direction="horizontal" width="200">
        <mx:RadioButtonGroup id="sexRBG">
            <mx:RadioButton id="maleRB" groupName="sexRBG" label="
" value="1"/>
            <mx:RadioButton id="femaleRB" groupName="sexRBG" label="
" value="0"/>
        </mx:RadioButtonGroup>
   </mx:FormItem>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值