Jquery客户端校验——jquery.validate.js
jQuery Validate 插件为表单提供了强大的验证功能,让客户端表单验证变得更简单,同时提供了大量的定制选项,满足应用程序各种需求。该插件捆绑了一套有用的验证方法,包括 URL 和电子邮件验证,同时提供了一个用来编写用户自定义方法的 API。使用方法如下
1.引用JS库
<script src="../Script/jquery.js" type="text/javascript"></script>
<script src="../Script/jquery.validate.js" type="text/javascript"></script>
2.校验规则:
3. .NET MVC Demo应用案例:
<body class="page-body login-page">
<script type="text/javascript">
jQuery(document).ready(function ($) {
$("form#login").validate({
rules: {
username: {
required: true,
maxlength:5
},
password: {
required: true,
maxlength:6
}
},
messages: {
username: {
required: 'Please enter your username.'
maxlength:$.validator.format( "Please enter no more than {0} characters." ),
},
password: {
required: 'Please enter your password.'
}
},
});
});
</script>
@using (Html.BeginForm("Index", "Home", FormMethod.Post,new {@id="login", @class = "login-form fade-in-effect" }))
{
<p>Dear user, log in to access the admin area!</p>
<div class="form-group">
<label class="control-label" for="username">Username</label>
<input type="text" class="form-control input-dark" name="username" id="username" autocomplete="off" />
</div>
<div class="form-group">
<label class="control-label" for="passwd">Password</label>
<input type="password" class="form-control input-dark" name="password" id="passwd" autocomplete="off" />
</div>
<div class="btn-white">
<p>
@Html.ValidationMessage("username")
@Html.ValidationMessage("password")
</p>
</div>
<div class="form-group">
<button type="submit" class="btn btn-white btn-block">
<i class="fa-lock"></i>
Log In
</button>
</div>
<div class="login-footer text-right">
<a href="#">忘记密码</a>
<a href="#">点击注册</a>
</div>
}
<!-- External login -->
<div class="external-login">
</div>
</div>
</div>
</div>
Jquery客户端校验——jquery.validate.js的更多相关文章
- jquery.validate.js校验select2解决方案,Jquery插件select2校验解决方案
jquery.validate.js校验select2解决方案 Jquery插件select2校验解决方案 >>>>>>>>>>>&g ...
- 通过jquery.validate.js校验表单字段是否合法
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- jquery.validate.js表单验证
一.用前必备官方网站:http://bassistance.de/jquery-plugins/jquery-plugin-validation/ API: http://jquery.bassist ...
- jQuery插件之验证控件jquery.validate.js
今天学习一下jQuery.Validate插件,为便于日后翻阅查看和广大博客园园友共享,特记于此. 本博客转载自:jQuery Validate jQuery Validate 插件为表单提供了强大的 ...
- 【转】jquery.validate.js表单验证
一.用前必备官方网站:http://bassistance.de/jquery-plugins/jquery-plugin-validation/ API: http://jquery.bassist ...
- [转]jquery.validate.js表单验证
原文地址:https://www.cnblogs.com/si-shaohua/p/3780321.html 一.用前必备官方网站:http://bassistance.de/jquery-plugi ...
- jQuery验证控件jquery.validate.js使用说明
官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation jQuery plugin: Validation 使用说明 转载 ...
- jquery.validate.js插件使用
jQuery验证控件jquery.validate.js使用说明+中文API 官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-valid ...
- jQuery验证控件jquery.validate.js使用说明+中文API
官网地址:http://bassistance.de/jquery-plugins/jquery-plugin-validation jQuery plugin: Validation 使用说明 学习 ...
随机推荐
- 第10章 Shell编程(1)_正则表达式
1. 基础的正则表达式 1.1 正则表达式与通配符 (1)正则表达式用来在文件中匹配符合条件的字符串,正则是包含匹配.grep.awk.sed等命令可以支持正则表达式. (2)通配符用来匹配符合条件的 ...
- Java学习笔记-抽象
开发软件的关键在于应用抽象的概念.方法抽象是通过将方法的使用和它的实现分离来实现的.方法的实现对用户隐藏在"黑匣子"中. 当编写一个大程序时,可以使用分治的策略,也成为逐步求精,将 ...
- [LeetCode] Rank Scores 分数排行
Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ra ...
- 【BZOJ-2938】病毒 Trie图 + 拓扑排序
2938: [Poi2000]病毒 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 609 Solved: 318[Submit][Status][Di ...
- bzoj1415[NOI2005]聪聪和可可
之前做的一些图上的期望步数的题大多用到高斯消元来求解(HNOI游走,SDOI走迷宫,etc),因此我一开始做这道题的时候想偏了- 这道题的性质:聪聪和可可之间的最短路长度严格递减.因为聪聪总可以多走一 ...
- shell脚本自动拉起启动程序
一.我们先看看编写的shell脚本的内容,该shell的作用主要是实现监控某个程序崩溃之后就自动重启该进程. while true do procnum=` ps -ef|grep "tes ...
- note
John的博客 http://blog.sina.com.cn/chinatownjohn 剑4-11真题+新东方pdf,王陆语料库(听力)+顾家北手把手教你写剑9版(写作)+人人雅思哥记忆卡(口语) ...
- Redis连接
using System; using System.Configuration; using StackExchange.Redis; namespace Redis { public sealed ...
- docker run elasticsearch
docker run -d --name=esNode1 -p 9200:9200 -p 9300:9300 elasticsearch:2.3 -Des.network.publish_host=& ...
- Spring-----定时任务Quartz配置之手动设置
一 配置xml如下: <!-- 定时任务配置 --> <bean id="scheduler" class="org.springframework.s ...