jQuery表单验证插件

表单验证插件
在这里插入图片描述
表单验证规则
在这里插入图片描述

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<style>
			#myform label.error{
				color: #FF0000;
			}
		</style>
		<script src="js/jquery-3.3.1.js"></script>
		//引入表单验证插件
		<script src="js/jquery.validate.js"></script>
		<script>
			//区分java的类方法以及对象方法
			//类方法:类.getcon;
			//对象方法:student sd=new student;sd.addstu;
			
			
			$(function(){
				//继承
// 				var s1={};
// 				var s2={"name":"大哥","age":18};
// 				$.extend(s1,s2);
				
				
				//$.extend()扩展类方法
// 				$.extend({
// 					abcd:function(){
// 						alert(123);
// 					},
// 					getmax:function(a,b){
// 						return a>b?a:b;
// 					},
// 					getmin:function(a,b){
// 						return a<b?a:b;
// 					}
// 				})
// 				var min=$.getmin(10,40);
// 				console.info(min);
				// $.abcd();
				
				//$.fn.extend()扩展对象方法
// 				$.fn.extend({
// 					xx:function(){
// 						$(this).each(function(i,ck){
// 							ck.checked=true;
// 						})
// 					},
// 					yy:function(){
// 						$(this).each(function(i,ck){
// 							ck.checked=false;
// 						})
// 					}
// 				})
// 				$("#ok").click(function(){
// 					$(".xz").xx();
// 				})
// 				$("#nook").click(function(){
// 					$(".xz").yy();
// 				})
// 				
// 				$("#qx").click(function(){
// 					if($(this).prop("checked")){
// 						$(".xz").xx();
// 					}else{
// 						$(".xz").yy();
// 					}
// 				})
				
				$("#myform").validate({
					rules:{
						uname:"required"
					},messages:{
						uname:"用户名不能为空",
					}
				})
				
				
				
				
			})
		</script>
	</head>
	<body>
		<input type="button" value="全选" id="ok"/>
		<input type="button" value="取消全选" id="nook"/>
		<input type="checkbox" value="全选" id="qx"/>全选
		<input type="checkbox" value="打篮球" class="xz"/>
		<input type="checkbox" value="打王者" class="xz"/>
		<input type="checkbox" value="打lol" class="xz"/>
		
		<form id="myform">
			用户名:<input type="text" name="uname" />
			密码:<input type="text" name="upwd" />
			<input type="submit" value="提交" />
			
		</form>
		
		
	</body>
</html>

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值