1.引用如下js和css 代码

    <link href="@Url.Content("~/Content/Site.css")" rel="stylesheet"
type="text/css" />
<link href="@Url.Content("~/Content/themes/base/jquery.ui.theme.css")" rel="stylesheet"
type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")"
type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")"
type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery.validate.min.js")"
type="text/javascript"></script>

2.验证代码

 <script type="text/javascript">

     $(document).ready(function () {
$("form").validate({
rules :{
titlenew: { required: true }, }, messages: {
titlenew: { required: "请输入姓名" }, }
});
});
</script>

3. html代码

@using(Html.BeginForm("form")){

    @Html.TextBoxFor(m => m.titlenew);
@Html.ValidationMessage("titlenew");
<input type="submit" value="提交"/>
}

点击提交,将会出现“请输入姓名”的提示

MVC笔记2:mvc+jquery.validate.js 进行前端验证的更多相关文章

  1. Jquery.validate.js表单验证插件的使用

    作为一个网站web开发人员,以前居然不知道还有表单验证这样好呀的插件,还在一行行写表单验证,真是后悔没能早点知道他们的存在. 最近公司不忙,自己学习一些东西的时候,发现了validation的一个实例 ...

  2. jquery.validate.js使用id验证控件

    jquery.validate.js默认的是元素的name. 例如:<input name="username" id="username" size=& ...

  3. jQuery.validate.js表单验证插件

    jQuery.validate.js表单验证插件的使用 效果: 代码: <!DOCTYPE html> <html lang="en"> <head& ...

  4. jquery.validate.js表单验证

    一.用前必备官方网站:http://bassistance.de/jquery-plugins/jquery-plugin-validation/ API: http://jquery.bassist ...

  5. jquery.validate.js 表单验证简单用法

    引入jquery.validate.js插件以及Jquery,在最后加上这个插件的方法名来引用.$('form').validate(); <!DOCTYPE html PUBLIC " ...

  6. 表单验证代码实例:jquery.validate.js表单验证插件

    jquery.validate.js是JQuery旗下的一个验证插件,借助JQuery的优势,我们可以迅速验证一些常见的输入,并且可以自己扩充自己的验证方法.使用前请先下载必要的JQuery插件:jq ...

  7. jquery validate.js表单验证的基本用法入门

    这里转载一篇前辈写的文章,在我自己的理解上修改了一下,仅作记录. 先贴一个国内某大公司的代码: 复制代码 代码如下: <script type="text/javascript&quo ...

  8. 【转】jquery.validate.js表单验证

    一.用前必备官方网站:http://bassistance.de/jquery-plugins/jquery-plugin-validation/ API: http://jquery.bassist ...

  9. [转]jquery.validate.js表单验证

    原文地址:https://www.cnblogs.com/si-shaohua/p/3780321.html 一.用前必备官方网站:http://bassistance.de/jquery-plugi ...

随机推荐

  1. C#中:函数访问级别对函数形参访问级别的约束

    Inconsistent accessibility: parameter type 'Program.CommandLineInfo' is less accessible than method ...

  2. Chapter 1 First Sight——16

    I drove around the school, following the line of traffic. 我开车绕学校随着交通线. 我开车穿过校园,紧跟着大部队. I was glad to ...

  3. PAT1016

    A long-distance telephone company charges its customers by the following rules: 一个长途电话公司费用告诉它的顾客需要遵循 ...

  4. java文件处理之压缩,分割

    http://blog.csdn.net/ycg01/article/details/1366648 java文件处理之压缩,分割 标签: javaexceptionimportnullbytefil ...

  5. 为什么有时候必须添加sys.setdefaultencoding('utf-8')

    今天在尝试Python的CGI模块时遇到中文字符不能正确显示的问题,很郁闷.在网上仔细找了找,终于解决了这个问题,现在将解决方法陈述如下,以防下次失误. 页面源代码如下 #-*- coding: ut ...

  6. jq的事件对象的属性

    1.event.type() 该方法的作用是可以获取到时间的类型 $('a').click(function(){ alert(event.type);//获取事件类型 return  false;/ ...

  7. windows加固方案

    1     账号管理.认证授权.... 1 1.1      账号... 1 1.2      口令... 1 1.3      授权... 2 2     日志配置操作.... 3 3     IP ...

  8. Git 学习资源

    在线教程 Try Git: Git初学者绝不能错过的Git上手资源. 廖雪峰Git教程: 比较系统的中文在线教程 易百Git教程 : 另一个比较全的中文在线教程 Git Immersion : A V ...

  9. HDU 5523 Game

    坑题 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> us ...

  10. 修炼dp( 2 )

    P1084 数字三角形4 题解:dp+dfs. #include <iostream> #include <cstdio> #include <algorithm> ...