加入收藏 | 设为首页 | 会员中心 | 我要投稿 河北网 (https://www.hebeiwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 业界 > 正文

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

发布时间:2018-08-18 04:44:33 所属栏目:业界 来源:站长网
导读:本日把 jquery.validate.js 下载下来,看了下它给的demo。此刻来总结下条记。 jquery.validate.js 官网下载:http://bassistance.de/jquery-plugins/jquery-plugin-validation/ 在上面可以下载到它的例子措施和js剧本 声名:本人看了下例子措施,有什么不

本日把 jquery.validate.js 下载下来,看了下它给的demo。此刻来总结下条记。

jquery.validate.js 官网下载:http://bassistance.de/jquery-plugins/jquery-plugin-validation/

在上面可以下载到它的例子措施和js剧本

声名:本人看了下例子措施,有什么差池的请各人指正。感谢!

行使它验证表单有2中方法:

1.行使它内部界说好的验证(也就是错误提醒它已经界说好了。不必要我们再界说,这种利便,简朴。但不机动。)

2.自界说错误提醒,这种可以本身界说错误提醒。必要写的代码就相对较多了。

实例1、行使jquery验证界说好的错误提醒。

一。我们先建一个表单,什么验证也没有的一个表单。

Copy to ClipboardLiehuo.Net Codes引用的内容:[www.veryhuo.com] <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="jquery_asp.net._Default" %>
<!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 runat="server">
<title>jquery validate </title>
</head>
<body>
<form id="commentForm" method="get" action="">
<fieldset>
<legend>请输入你的姓名,电子邮件和网址,以及你的评述</legend>
<p>
<label for="cname">姓名(必填,并2个字符)</label>
<input id="cname" name="name" />
<p>
<label for="cemail">电子邮件 (必填)</label>
<input id="cemail" name="email" />
</p>
<p>
<label for="curl">网址 (可选)</label>
<input id="curl" name="url"value="" />
</p>
<p>
<label for="ccomment">你的评述 (必填)</label>
<textarea id="ccomment" name="comment"></textarea>
</p>
<p>
<input type="submit" value="提交"/>
</p>
</fieldset>
</form>
</body>
</html>

2.添加验证

此刻我们来添加验证。

1.引入jquery剧本

<script type="text/javascript" src="http://www.veryhuo.com/uploads/Common/jquery-1.3.2.min.js"></script>
<script src="http://www.veryhuo.com/uploads/Common/js/jquery.validate.js" type="text/javascript"></script>

(编辑:河北网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读