Stingray验证机制
Filter
系统中的验证使用的是Filter库来完成,利用Filter配置几个属性和参数就实现了表单验证,简化了工作。基本原理很简单,在onload之后按照属性查找元素,然后绑定相应的change/blur事件,当表单数据发生变动的时候就会触发验证函数。
Filter示例
日期格式的例子:
<!--下面这些必不可少
filter="DATE" dtype="" param=""
class="hasDatepicker"
-->
<div class="component EditorText" ref="EditorText" filter="DATE" param dtype>
<SPAN class="notRequired hasDatepicker">Date Scanned</SPAN>
<INPUT id="Scaned_Date1" name="Scaned_Date1">
</div>
<!--整型-->
<div style="left:0px;top:5px;" class="component EditorText" ref="EditorText" filter="INTEGER" dtype="" param="">
<SPAN style="FONT-SIZE: 1em; CURSOR: text" class=notRequired>xxx</SPAN>
<INPUT style="width:250px" id="xxxxxxxxxxxxxx" title="Please click here to enter the inspection date." tabindex="0" name="xxxxxxxxxxxxxx" maxLength=50>
</div>
<!--金额-->
<div style="left:0px;top:5px;" class="component EditorText" ref="EditorText" filter="MONEY" dtype="" param="">
<SPAN style="FONT-SIZE: 1em; CURSOR: text" class=notRequired>xxx</SPAN>
<INPUT style="width:250px" id="xxxxxxxxxxxxxx" title="Please click here to enter the inspection date." tabindex="0" name="xxxxxxxxxxxxxx" maxLength=50>
</div>
<!--email-->
<div style="left:0px;top:5px;" class="component EditorText" ref="EditorText" filter="EMAIL" dtype="" param="">
<SPAN style="FONT-SIZE: 1em; CURSOR: text" class=notRequired>xxxx</SPAN>
<INPUT style="width:250px" id="xxxxxxxxxxxxxx" title="Please click here to enter the inspection date." tabindex="0" name="xxxxxxxxxxxxxx" maxLength=50>
</div>
手动触发验证
Validator.Filters.GREATERTHANEQUALS.filter(credit_debit, "FLOAT", 0);
所有的Filter列表
DATE
EMAIL
EMAILS
EQUAL
FEIN
FLOAT
INTEGER
MONEY
PASSWORD
PHONE
SSN
STATE
TIME
ZIPCODE
GREATERTHAN
GREATERTHANEQUALS
LESSTHAN
LESSTHANEQUALS
CUSTOMEXPRESSION
CUSTOMFUNCTION
带参数多Filter的配置
<div class="component EditorText" ref="EditorText" style="" filter="DATE|GREATERTHANEQUALS|LESSTHANEQUALS" dtype="|DATE|DATE" param="|01/01/1900|01/01/2100">
<span class="hasDatepicker required" style="">Effective Date</span>
<input id="PQ_EffectiveDate" name="PQ_EffectiveDate" maxlength="10" class="hasDatepicker" style="width: 150px;" tabindex="0" title="" type="text" value="10/14/2014">
</div>
filter="INTEGER" param="" dtype="INTEGER"
filter="MONEY" param="" dtype=""
filter="DATE" param="" dtype=""
filter="DATE|GREATERTHANEQUALS" dtype="|DATE" param="|01/01/1900"
filter="DATE|GREATERTHANEQUALS|LESSTHANEQUALS" dtype="|DATE|DATE" param="|01/01/1900|01/01/2100"
filter="STATE" param="" dtype=""
filter="INTEGER|GREATERTHAN" param="|0" dtype="|INTEGER"
filter="FLOAT|GREATERTHAN" param="|0" dtype="|FLOAT"
filter="PHONE" param="" dtype=""
filter="LESSTHANEQUALS|GREATERTHANEQUALS" param="999999|1000" dtype="FLOAT|FLOAT"
正则式实现验证
如何使用正则式实现验证参考这篇文章:JavaScript正则式入门
Stingray验证机制的更多相关文章
- 【MVC】ASP.NET MVC Forms验证机制
http://www.cnblogs.com/bomo/p/3309766.html 随笔 - 121 文章 - 0 评论 - 92 [MVC]ASP.NET MVC Forms验证机制 ASP. ...
- jquery.validate 验证机制
jquery.validate 验证机制 金刚 juqery juqery.validate 在开发系统时,使用了jquery.validate.js 这个验证插件,来校验数据合法性 重点 验证是以i ...
- 定制Asp.NET 5 MVC内建身份验证机制 - 基于自建SQL Server用户/角色数据表的表单身份验证
背景 在需要进行表单认证的Asp.NET 5 MVC项目被创建后,往往需要根据项目的实际需求做一系列的工作对MVC 5内建的身份验证机制(Asp.NET Identity)进行扩展和定制: Asp.N ...
- Linux登录验证机制、SSH Bruteforce Login学习
相关学习资料 http://files.cnblogs.com/LittleHann/linux%E4%B8%AD%E7%94%A8%E6%88%B7%E7%99%BB%E5%BD%95%E8%AE% ...
- Google 推出全新的两步验证机制
近日 Google 在官方的 Apps Updates 博客公布了全新的两步验证功能--Google 提示,新的功能通过与 Google App 联动,进一步将验证确认工作缩减到仅有两步,同时支持 A ...
- ASP.NET MVC- 数据验证机制
ASP.NET MVC的数据验证机制,比起ASP.NET WEBFORM那种高效很多.下面记录以下两个示例,以便日后方便查阅. 方式一:在Controller里通过AddModelError方法返回错 ...
- 通过扩展改善ASP.NET MVC的验证机制[实现篇]
原文:通过扩展改善ASP.NET MVC的验证机制[实现篇] 在<使用篇>中我们谈到扩展的验证编程方式,并且演示了本解决方案的三大特性:消息提供机制的分离.多语言的支持和多验证规则的支持, ...
- 通过扩展改善ASP.NET MVC的验证机制[使用篇]
原文:通过扩展改善ASP.NET MVC的验证机制[使用篇] ASP.NET MVC提供一种基于元数据的验证方式是我们可以将相应的验证特性应用到作为Model实体的类型或者属性/字段上,但是这依然具有 ...
- Python_socket常见的方法、网络编程的安全注意事项、socketsever模块、浏览器中在一段时间记录用户的登录验证机制
1.socket常见的方法 socket_常见方法_服务器端 import socket from socket import SOL_SOCKET,SO_REUSEADDR sk = socket. ...
随机推荐
- 读取 android sys/下的信息
读取 android sys/下的信息 https://github.com/ruw/Internet-Services-projects/tree/master/OffloadPredictor/l ...
- WordPress主题开发:开启feed功能
开启feed功能 步骤一:在模版文件的<head></head>元素中添加wp_head()函数,且wp_head()函数要放在</head>标签之前,而且紧邻&l ...
- fastjson转换对象,属性首字母大小写的问题
请求Json数据的时候,传递过去的String类型转Json数据的时候经常有首字母是大写的情况,例如"LoginAccount":"02:00:00:62:73:74&q ...
- Java工程师成神之路~(2018修订版)
针对本文,博主最近在写<成神之路系列文章> ,分章分节介绍所有知识点.欢迎关注. 主要版本 更新时间 备注 v1.0 2015-08-01 首次发布 v1.1 2018-03-12 增加新 ...
- Error:Program type already present: android.arch.lifecycle.LiveData
Apparently, this is intended behavior: com.firebaseui:firebase-ui-firestore:3.1.0 depends on android ...
- 使用PHP生成二维码图像
1.PHP生成二维码图像的类QRcode http://www.phper.org.cn/?post=128 QRcode是用于生成二维条形码的开放源码 (LGPL) 库.提供 API 创建条码图像. ...
- Inferred type 'S' for type parameter 'S' is not within its bound; should extend
在使用springboot 方法报错: Inferred type 'S' for type parameter 'S' is not within its bound; should extends ...
- C# Encoding UTF-16 ,C#中的UTF16
http://www.cnblogs.com/criedshy/archive/2012/08/07/2625358.html 前言 众所周知计算机只能识别二进制数字,如1010,1001.我们屏幕所 ...
- POJ训练计划2528_Mayor's posters(线段树/成段更新+离散化)
解题报告 id=2528">地址传送门 题意: 一些海报,覆盖上去后还能看到几张. 思路: 第一道离散化的题. 离散化的意思就是区间压缩然后映射. 给你这么几个区间[1,300000] ...
- 看看Spring的源码(一)——Bean加载过程
首先Web项目使用Spring是通过在web.xml里面配置org.springframework.web.context.ContextLoaderListener初始化IOC容器的. <li ...