miniui表单验证守则总结
1,页面效果图
2,代码实现
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml"> | |
| <head> | |
| <title>表单验证规则总结</title> | |
| <meta http-equiv="content-type" content="text/html; charset=UTF-8" /><link href="../demo.css" rel="stylesheet" type="text/css" /> | |
| <script src="../../scripts/boot.js" type="text/javascript"></script> | |
| <style type="text/css"> | |
| .td1 | |
| { | |
| text-align:right; | |
| } | |
| .td2 | |
| { | |
| padding-left:15px; | |
| font-size:13px; | |
| font-family:Tahoma; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <h1>表单验证规则总结</h1> | |
| <div id="form1" > | |
| <table> | |
| <tr> | |
| <td class="td1">不允许为空:</td> | |
| <td> | |
| <input class="mini-textbox" required="true" /> | |
| </td> | |
| <td class="td2">required="true"</td> | |
| </tr> | |
| <tr> | |
| <td class="td1">必须是邮箱地址:</td> | |
| <td> | |
| <input class="mini-textbox" vtype="email" required="true"/> | |
| </td> | |
| <td class="td2">vtype="email"</td> | |
| </tr> | |
| <tr> | |
| <td class="td1">必须是URL:</td> | |
| <td> | |
| <input class="mini-textbox" vtype="url" required="true"/> | |
| </td> | |
| <td class="td2">vtype="url"</td> | |
| </tr> | |
| <tr> | |
| <td class="td1">必须是整数(int):</td> | |
| <td> | |
| <input class="mini-textbox" vtype="int" required="true"/> | |
| </td> | |
| <td class="td2">vtype="int"</td> | |
| </tr> | |
| <tr> | |
| <td class="td1">必须是数字(float):</td> | |
| <td> | |
| <input class="mini-textbox" vtype="float" required="true"/> | |
| </td> | |
| <td class="td2">vtype="float"</td> | |
| </tr> | |
| <tr> | |
| <td class="td1">字符串长度(<= 6):</td> | |
| <td> | |
| <input class="mini-textbox" vtype="maxLength:6" required="true"/> | |
| </td> | |
| <td class="td2">vtype="maxLength:6"</td> | |
| </tr> | |
| <tr> | |
| <td class="td1">字符串长度(>= 2):</td> | |
| <td> | |
| <input class="mini-textbox" vtype="minLength:2" required="true"/> | |
| </td> | |
| <td class="td2">vtype="minLength:2"</td> | |
| </tr> | |
| <tr> | |
| <td class="td1">字符串长度(2-6):</td> | |
| <td> | |
| <input class="mini-textbox" vtype="rangeLength:2,6" required="true"/> | |
| </td> | |
| <td class="td2">vtype="rangeLength:2,6"</td> | |
| </tr> | |
| <tr> | |
| <td class="td1">字符数个数(2-6):</td> | |
| <td> | |
| <input class="mini-textbox" vtype="rangeChar:2,6" required="true"/> | |
| </td> | |
| <td class="td2">vtype="rangeChar:2,6"</td> | |
| </tr> | |
| <tr> | |
| <td class="td1">数字范围(0-100):</td> | |
| <td> | |
| <input class="mini-textbox" vtype="range:0,100" required="true"/> | |
| </td> | |
| <td class="td2">vtype="range:0,100"</td> | |
| </tr> | |
| <tr> | |
| <td class="td1">必须是日期格式(如yyyy-MM-dd):</td> | |
| <td> | |
| <input class="mini-textbox" vtype="date:yyyy-MM-dd" required="true"/> | |
| </td> | |
| <td class="td2">vtype="date:yyyy-MM-dd"</td> | |
| </tr> | |
| <tr> | |
| <td class="td1">必须是日期格式(如MM/dd/yyyy):</td> | |
| <td> | |
| <input class="mini-textbox" vtype="date:MM/dd/yyyy" required="true"/> | |
| </td> | |
| <td class="td2">vtype="date:MM/dd/yyyy"</td> | |
| </tr> | |
| <tr> | |
| <td class="td1" style="color:Red;">邮箱格式,5~20个字符(组合):</td> | |
| <td> | |
| <input class="mini-textbox" vtype="email;rangeLength:5,20;" required="true"/> | |
| </td> | |
| <td class="td2">vtype="email;rangeLength:5,20;"</td> | |
| </tr> | |
| <tr> | |
| <td class="td1" style="color:Red;">必须输入英文(自定义):</td> | |
| <td> | |
| <input class="mini-textbox" onvalidation="onEnglishValidation" /> | |
| </td> | |
| <td class="td2">onvalidation="onEnglishValidation"</td> | |
| </tr> | |
| <tr> | |
| <td class="td1" style="color:blue;">必须输入英文(自定义vtype):</td> | |
| <td> | |
| <input class="mini-textbox" vtype="english"/> | |
| </td> | |
| <td class="td2">vtype="english"</td> | |
| </tr> | |
| <tr> | |
| <td class="td1" style="color:Red;">必须输入英文+数字(自定义):</td> | |
| <td> | |
| <input class="mini-textbox" onvalidation="onEnglishAndNumberValidation" /> | |
| </td> | |
| <td class="td2">onvalidation="onEnglishAndNumberValidation"</td> | |
| </tr> | |
| <tr> | |
| <td class="td1" style="color:Red;">必须输入中文(自定义):</td> | |
| <td> | |
| <input class="mini-textbox" onvalidation="onChineseValidation" /> | |
| </td> | |
| <td class="td2">onvalidation="onChineseValidation"</td> | |
| </tr> | |
| <tr> | |
| <td class="td1" style="color:Red;">身份证验证15~18位(自定义):</td> | |
| <td> | |
| <input class="mini-textbox" onvalidation="onIDCardsValidation" /> | |
| </td> | |
| <td class="td2">onvalidation="onIDCardsValidation"</td> | |
| </tr> | |
| <tr> | |
| <td></td> | |
| <td> | |
| <input value="Login" type="button" onclick="submitForm()" /> | |
| </td> | |
| </tr> | |
| </table> | |
| </div> | |
| <script type="text/javascript"> | |
| mini.parse(); | |
| function submitForm() { | |
| var form = new mini.Form("#form1"); | |
| form.validate(); | |
| if (form.isValid() == false) return; | |
| //提交数据 | |
| var data = form.getData(); | |
| var json = mini.encode(data); | |
| $.ajax({ | |
| url: "../data/FormService.aspx?method=SaveData", | |
| type: "post", | |
| data: { submitData: json }, | |
| success: function (text) { | |
| alert("提交成功,返回结果:" + text); | |
| } | |
| }); | |
| } | |
| //////////////////////////////////////// | |
| function onEnglishValidation(e) { | |
| if (e.isValid) { | |
| if (isEnglish(e.value) == false) { | |
| e.errorText = "必须输入英文"; | |
| e.isValid = false; | |
| } | |
| } | |
| } | |
| function onEnglishAndNumberValidation(e) { | |
| if (e.isValid) { | |
| if (isEnglishAndNumber(e.value) == false) { | |
| e.errorText = "必须输入英文+数字"; | |
| e.isValid = false; | |
| } | |
| } | |
| } | |
| function onChineseValidation(e) { | |
| if (e.isValid) { | |
| if (isChinese(e.value) == false) { | |
| e.errorText = "必须输入中文"; | |
| e.isValid = false; | |
| } | |
| } | |
| } | |
| function onIDCardsValidation(e) { | |
| if (e.isValid) { | |
| var pattern = /\d*/; | |
| if (e.value.length < 15 || e.value.length > 18 || pattern.test(e.value) == false) { | |
| e.errorText = "必须输入15~18位数字"; | |
| e.isValid = false; | |
| } | |
| } | |
| } | |
| //////////////////////////////////// | |
| /* 是否英文 */ | |
| function isEnglish(v) { | |
| var re = new RegExp("^[a-zA-Z\_]+$"); | |
| if (re.test(v)) return true; | |
| return false; | |
| } | |
| /* 是否英文+数字 */ | |
| function isEnglishAndNumber(v) { | |
| var re = new RegExp("^[0-9a-zA-Z\_]+$"); | |
| if (re.test(v)) return true; | |
| return false; | |
| } | |
| /* 是否汉字 */ | |
| function isChinese(v) { | |
| var re = new RegExp("^[\u4e00-\u9fa5]+$"); | |
| if (re.test(v)) return true; | |
| return false; | |
| } | |
| /*自定义vtype*/ | |
| mini.VTypes["englishErrorText"] = "请输入英文"; | |
| mini.VTypes["english"] = function (v) { | |
| var re = new RegExp("^[a-zA-Z\_]+$"); | |
| if (re.test(v)) return true; | |
| return false; | |
| } | |
| </script> | |
| <div class="description"> | |
| <h3>Description</h3> | |
| <p> | |
| </p> | |
| </div> | |
| </body> | |
| </html> |
miniui表单验证守则总结的更多相关文章
- MiniUI表单验证总结
原文地址:https://www.cnblogs.com/wllcs/p/5607890.html 1,页面效果图 2,代码实现 <!DOCTYPE html PUBLIC "-/ ...
- Miniui 表单验证
自定义表单验证: input输入框的表单验证可通过vtype和onvalidation事件两种方式实现 可编辑列表(例如div)的表单验证只能通过vtye来实现表单验证 (1)vtype方式: jsp ...
- MiniUI表单验证实践
学习实践: <form id="form2"> <div id="update_pas" style="width:380px&qu ...
- MiniUI官方表单验证示例
原文地址:http://www.miniui.com/docs/tutorial/validator.html 表单验证 参考示例: 验证规则 表单验证 表单验证:文本提示 表 ...
- miniui中表单验证规则总结
页面链接: http://www.miniui.com/demo/#src=form/rules.html 页面效果图: 页面代码: <!DOCTYPE html PUBLIC "-/ ...
- jQuery学习之路(8)- 表单验证插件-Validation
▓▓▓▓▓▓ 大致介绍 jQuery Validate 插件为表单提供了强大的验证功能,让客户端表单验证变得更简单,同时提供了大量的定制选项,满足应用程序各种需求.该插件捆绑了一套有用的验证方法,包括 ...
- 玩转spring boot——AOP与表单验证
AOP在大多数的情况下的应用场景是:日志和验证.至于AOP的理论知识我就不做赘述.而AOP的通知类型有好几种,今天的例子我只选一个有代表意义的“环绕通知”来演示. 一.AOP入门 修改“pom.xml ...
- form表单验证-Javascript
Form表单验证: js基础考试内容,form表单验证,正则表达式,blur事件,自动获取数组,以及css布局样式,动态清除等.完整代码如下: <!DOCTYPE html PUBLIC &qu ...
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(33)-MVC 表单验证
系列目录 注:本节阅读需要有MVC 自定义验证的基础,否则比较吃力 一直以来表单的验证都是不可或缺的,微软的东西还是做得比较人性化的,从webform到MVC,都做到了双向验证 单单的用js实现的前端 ...
随机推荐
- Unity Remote 5 使用
从哪里下载,我是从应用商店里下载的 一. Android版 首先应该确保安装了最新的 Android SDK(这对于在设备上设置端口转发非常必要). 然后,使用 USB 连接线连接设备与电脑,并启动U ...
- HP发送HTTP POST请求 返回结果
HP发送HTTP POST请求 返回结果 <?php $srv_ip = '192.168.10.188';//你的目标服务地址或频道.$srv_port = 80;$url = '/demo/ ...
- 226. Invert Binary Tree 翻转二叉树
[抄题]: Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 [暴力解法]: 时间分析: 空间分 ...
- list count++
AtomicInteger count = customTypeCounter.get(order.getCustomerType()); if (count == null) { count = n ...
- libpcap编程实例
#include <stdio.h> #include <stdlib.h> #include <pcap.h> #include <errno.h> ...
- [SoapUI] 在Test Step 下加Script Assertion,用 messageExchange 获取当前步骤的response content
//Get response content of the current request def response = messageExchange.getResponseContent() // ...
- [Fiddler] 在 Composer 中对HTTP报文进行编辑,重新执行
如果想要对某个HTTP请求进行编辑,然后重新执行观察结果,可以将这个报文从左侧拖放到右侧的Composer里面 这样就可以很方便的修改HTTP请求的方法,报文头,报文体 在用 SoapUI 做 API ...
- vs + wsl .net core 远程调试 (linux vsdbg)
https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes https://github.com/ ...
- 白盒测试实践项目(day2)
到目前为止: 李建文同学大体完成代码复审,并在完善文档,汪鸿同学和杨瑞丰同学都在熟悉各自的任务,胡俊辉同学设计了JUnit测试用例,张颖同学负责维护这几天的博客. 目前小组成员还未碰到不能解决的问题. ...
- logcat命令详解【一】
Android日志系统提供了记录和查看系统调试信息的功能.日志都是从各种软件和一些系统的缓冲区中记录下来的,缓冲区可以通过logcat命令来查看和使用. 在使用logcat之前,请确保手机的USB调试 ...