1 validate

<?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" minWidth="955" minHeight="600"> <fx:Declarations>
<mx:Validator source="{username}" property="text" required="true" />
</fx:Declarations>
<s:VGroup horizontalCenter="0" verticalCenter="0">
<s:Label text="输入你的名字"/>
<s:TextInput id="username"/>
</s:VGroup> </s:Application>

2StringValidate

<?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" minWidth="955" minHeight="600"> <fx:Declarations>
<mx:StringValidator source="{username}" property="text" minLength="3" maxLength="20"
trigger="{submitButton}" triggerEvent="click"
tooShortError="最少要有3个字符"
tooLongError="最多只能20个字符"
> </mx:StringValidator>
</fx:Declarations>
<s:VGroup horizontalCenter="0" verticalCenter="0">
<s:Label text="输入你的名字"/>
<s:TextInput id="username"/>
<s:Button label="Submit" id="submitButton"/>
</s:VGroup> </s:Application>

3 NumberValidator

<?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" minWidth="" minHeight=""> <fx:Declarations>
<mx:NumberValidator source="{age}" property="text" allowNegative="false"
negativeError="年龄不太对昂"
minValue="" maxValue="" domain="int"
trigger="{submitButton}" triggerEvent="click" />
</fx:Declarations>
<s:VGroup horizontalCenter="" verticalCenter="">
<s:Label text="输入你的年龄"/>
<s:TextInput id="age" />
<s:Button label="Submit" id="submitButton"/> </s:VGroup> </s:Application>

但是 negativeError="报错内容"  似乎不太起作用

4 DateVlidator

<?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" minWidth="955" minHeight="600"> <fx:Declarations>
<mx:DateValidator source="{birthday}" property="text" inputFormat="mm/dd/yyyy" allowedFormatChars="/"
trigger="{submitButton}" triggerEvent="click"
/>
</fx:Declarations>
<s:VGroup horizontalCenter="0" verticalCenter="0">
<s:Label text="请输入日期"/>
<s:TextInput id="birthday"/>
<s:Button label="Submit" id="submitButton"/>
</s:VGroup> </s:Application>

5 dateValidator 具体到日月年

<?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" minWidth="955" minHeight="600"> <fx:Declarations>
<mx:DateValidator
monthSource="{month}" monthProperty="value" daySource="{day}" dayProperty="value" yearSource="{year}" yearProperty="text"
property="text" inputFormat="mm/dd/yyyy" allowedFormatChars="/"
trigger="{submitButton}" triggerEvent="click"
/>
</fx:Declarations>
<s:VGroup horizontalCenter="0" verticalCenter="0">
<s:Label text="请输入日期月"/>
<s:NumericStepper id="month"/>
<s:Label text="请输入日期日"/>
<s:NumericStepper id="day"/>
<s:Label text="请输入日期年"/>
<s:TextInput id="year" width="60"/>
<s:Button label="Submit" id="submitButton" />
</s:VGroup> </s:Application>

6 EmailValidator

<?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" minWidth="955" minHeight="600"> <fx:Declarations>
<mx:EmailValidator source="{email}" property="text"
invalidCharError="你输入的邮箱格式不正确"
trigger="{submitButton}" triggerEvent="click" />
</fx:Declarations>
<s:VGroup horizontalCenter="0" verticalCenter="0">
<s:Label text="Email:"/>
<s:TextInput id="email"/>
<s:Button label="提交" id="submitButton"/>
</s:VGroup> </s:Application>

7  CreditCardValidator

<?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" minWidth="955" minHeight="600">
<fx:Declarations>
<mx:CreditCardValidator
cardNumberSource="{cardNumber}"
cardNumberProperty="text"
cardTypeSource="{cardType}"
cardTypeProperty="selectedItem"
trigger="{submitButton}"
triggerEvent="click" />
</fx:Declarations>
<s:VGroup horizontalCenter="0" verticalCenter="0">
<s:DropDownList id="cardType" width="150">
<s:ArrayCollection>
<fx:String>American Express</fx:String>
<fx:String>Visa</fx:String>
<fx:String>Diners</fx:String>
<fx:String>Discover</fx:String>
<fx:String>MasterCard</fx:String>
</s:ArrayCollection>
</s:DropDownList>
<s:Label text="Card Number"/>
<s:TextInput id="cardNumber"/>
<s:Button label="Submit" id="submitButton"/>
</s:VGroup> </s:Application>

8 PhoneNumberValidator

8 RegExpValidator  正则表达式

ssn(Social Security Number)以美国社保账号为例

9用正则表达式 RegExpValidator  查找与模式匹配的所有匹配项

<?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" minWidth="955" minHeight="600">
<fx:Declarations>
<mx:RegExpValidator source="{ssn}" property="text"
flags="gmi"
expression="\d\{3\}.\d\{2\}.\d\{\4}"
noMatchError="你的社保账号输入的不正确"
trigger="{submitButton}"
triggerEvent="click"
> </mx:RegExpValidator> </fx:Declarations>
<s:VGroup horizontalCenter="0" verticalCenter="0">
<s:Label text="美国社保号"/>
<s:TextInput id="ssn"/>
<s:Button label="提交" id="submitButton"/>
</s:VGroup>
</s:Application>
flags="gmi" 是忽略大小写

10查找与模式匹配的所有匹配项
<?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" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.ValidationResultEvent;
import mx.validators.RegExpValidationResult;
private function handleValidation(event:ValidationResultEvent):void
{
var oneResult:RegExpValidationResult;
for(var i:int =0; i<event.results.length;i++)
{
oneResult = event.results[i];
Alert.show("找到一个匹配zaiindex中: "+ oneResult.matchedIndex +"\n在characters of"+oneResult.matchedString,"RegEx Results",Alert.NONMODAL);
}
}
]]>
</fx:Script>
<fx:Declarations>
<mx:RegExpValidator source="{test}" property="text" flags="gmi"
valid="handleValidation(event)"
expression="m[ai]n" noMatchError="我不喜欢这个"
trigger="{submitButton}" triggerEvent="click"/>
</fx:Declarations>
<s:VGroup horizontalCenter="0" verticalCenter="0"> <s:Label text="Try me:"/>
<s:TextInput id="test"/>
<s:Button label="Submit" id="submitButton" />
</s:VGroup>
</s:Application>

11 实时验证

<?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" minWidth="955" minHeight="600">
<fx:Declarations>
<mx:StringValidator source="{address}"
minLength="5" property="text"
trigger="{address}" triggerEvent="change"/> </fx:Declarations>
<s:VGroup horizontalCenter="0" verticalCenter="0">
<s:Label text="请输入你的地址"/>
<s:TextInput id="address"/>
<s:Button label="提交" id="submitButton" />
</s:VGroup>
</s:Application>

12 提交值验证,提交值包括Tab键、回车键、方向键或鼠标单击其他组件

<?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" minWidth="955" minHeight="600">
<fx:Declarations>
<mx:StringValidator source="{address}"
minLength="5" property="text"
trigger="{address}" triggerEvent="valueCommit"/> </fx:Declarations>
<s:VGroup horizontalCenter="0" verticalCenter="0">
<s:Label text="请输入你的地址"/>
<s:TextInput id="address"/>
<s:Button label="提交" id="submitButton" />
</s:VGroup>
</s:Application>

13 通过性验证

 
<?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" minWidth="955" minHeight="600">
<fx:Declarations>
<mx:StringValidator source="{username}"
minLength="6" property="text"
trigger="{submitButton}" triggerEvent="click"/>
<mx:EmailValidator source="{email}" property="text"
invalidCharError="你输入的邮箱格式不正确"
trigger="{submitButton}" triggerEvent="click" /> </fx:Declarations>
<s:VGroup horizontalCenter="0" verticalCenter="0">
<s:Label text="输入EMAIL"/>
<s:TextInput id="email"/>
<s:Label text="输入你的名字"/>
<s:TextInput id="username"/>
<s:Button label="Submit" id="submitButton"/>
</s:VGroup>
</s:Application>

Flex验证器 validate stringvalidate的更多相关文章

  1. thinkphp5 验证器 validate 和 layer

    首先tp5的验证器使用特方便 设置规则即可通用 首先页面html(layer 配合) 毕竟是后端 尽量用一些成熟的前台框架  之前用boostrap $.ajax({ url:'/index/Regi ...

  2. thinkphp5.0自定义验证器

    虽然我早就会些php基础语法,我套过数据,自己写的控制器层,不是用的api方式,那个公司是为了锻炼我,所以才那样做的,基本上的东西都是用的框架自带的,重来自己没有去封装过这些东西,所以编程思想上,还很 ...

  3. gin中如何自定义验证器

    package main import ( "github.com/gin-gonic/gin" "github.com/gin-gonic/gin/binding&qu ...

  4. Flex 内置验证器—验证用户输入

    今晚对于Flex中的Validator类(所有验证器的父类)测试一下 ---->其中常用的验证类有StringValidator,NumberValidator,DateValidator 测试 ...

  5. Thinkphp5中的Validate验证器的使用

    更多笔记: http://note.youdao.com/noteshare?id=e97a5df64888f27d912b3e966b9ec297&sub=web1520841813815 ...

  6. 9、 Struts2验证(声明式验证、自定义验证器)

    1. 什么是Struts2 验证器 一个健壮的 web 应用程序必须确保用户输入是合法.有效的. Struts2 的输入验证 基于 XWork Validation Framework 的声明式验证: ...

  7. vue-validator(vue验证器)

    官方文档:http://vuejs.github.io/vue-validator/zh-cn/index.html github项目地址:https://github.com/vuejs/vue-v ...

  8. 原生JS 表单提交验证器

    转载:http://www.cnblogs.com/sicd/p/4613628.html 一.前言 最近在开发一个新项目,需要做登陆等一系列的表单提交页面.在经过“缜密”的讨论后,我们决定 不用外部 ...

  9. yii框架中验证器声明一组内置验证器可以使用短名称引用

    1.内置验证器的短名称分别有: boolean: yii\validators\BooleanValidator captcha: yii\captcha\CaptchaValidator compa ...

随机推荐

  1. DS树+图综合练习--带权路径和

    题目描述 计算一棵二叉树的带权路径总和,即求赫夫曼树的带权路径和. 已知一棵二叉树的叶子权值,该二叉树的带权案路径和APL等于叶子权值乘于根节点到叶子的分支数,然后求总和.如下图中,叶子都用大写字母表 ...

  2. LeetCode——4. Median of Two Sorted Arrays

    一.题目链接:https://leetcode.com/problems/median-of-two-sorted-arrays 二.题目大意: 给定两个排序过的数组,求出两个数组的中位数,要求时间复 ...

  3. 【RPC】使用Hessian构建RPC的简单示例

    服务接口和实现 public interface HelloService { // 服务方法 String sayHello(String name); } public class HelloSe ...

  4. Hive之一:hive2.1.1安装部署

    一.Hive 运行模式 与 Hadoop 类似,Hive 也有 3 种运行模式: 1. 内嵌模式 将元数据保存在本地内嵌的 Derby 数据库中,这是使用 Hive 最简单的方式.但是这种方式缺点也比 ...

  5. 无法启动程序,因为计算机中丢失mfc90ud.dll的解决方案

    我的编程环境是vs2008-MFC,电脑系统是win7(64位) 解决方法:“工具”—>“选项”—>“项目和解决方案”—>“VC++目录”,在可执行文件栏中加上如下路径: $(Sys ...

  6. JAVA虚拟机关闭钩子(Shutdown Hook)

    程序经常也会遇到进程挂掉的情况,一些状态没有正确的保存下来,这时候就需要在JVM关掉的时候执行一些清理现场的代码.JAVA中的ShutdownHook提供了比较好的方案. JDK提供了Java.Run ...

  7. 一次cookie引起系统不断要求重新登录问题分析

    我们的产品里有一配置服务(tomcat),采用ajax来通信交互 但是最近频频发现登录后马上弹出要重新登录的情况,一开始以为是cookie没有带上导致session找不到,后来问题依旧,查看浏览器co ...

  8. HDOJ 2006 求奇数的乘积

    #include<iostream> #include<vector> using namespace std; int main() { int n; while (cin ...

  9. go语言学习--map的并发

    go提供了一种叫map的数据结构,可以翻译成映射,对应于其他语言的字典.哈希表.借助map,可以定义一个键和值,然后可以从map中获取.设置和删除这个值,尤其适合数据查找的场景.但是map的使用有一定 ...

  10. [UE4]Canvas Panel

    一.Canvas Panel:画布.Canvas Panel中内的元素可以任何摆放位置.Canvas Panel是UserWiget默认的根节点容器,可以把跟节点删除替换生成任何的UI元素. 二.选择 ...