首页 > 其他分享 >jQuery插件(jQuery validation)

jQuery插件(jQuery validation)

时间:2023-01-18 02:11:06浏览次数:60  
标签:jQuery 插件 用户名 name minlength 密码 validation

视频

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <style>
    .error {
      color: #F00;
    }
  </style>
</head>
<body>
<!--
    required: "This field is required.",
		remote: "Please fix this field.",
		email: "Please enter a valid email address.",
		url: "Please enter a valid URL.",
		date: "Please enter a valid date.",
		dateISO: "Please enter a valid date ( ISO ).",
		number: "Please enter a valid number.",
		digits: "Please enter only digits.",
		equalTo: "Please enter the same value again.",
		maxlength: $.validator.format( "Please enter no more than {0} characters." ),
		minlength: $.validator.format( "Please enter at least {0} characters." ),
		rangelength: $.validator.format( "Please enter a value between {0} and {1} characters long." ),
		range: $.validator.format( "Please enter a value between {0} and {1}." ),
		max: $.validator.format( "Please enter a value less than or equal to {0}." ),
		min: $.validator.format( "Please enter a value greater than or equal to {0}." ),
		step: $.validator.format( "Please enter a multiple of {0}." )
-->
<form id="myForm" action="xxx">
  <!-- action表单提交目标地址 -->
  <p>用户名(必须的, 最小2位): <input name="name" type="text" required minlength="2"></p>
  <p>密码(必须的, 6到8位): <input id="password" name="pwd" type="password" required minlength="6" maxlength="8"></p>
  <p>确认密码(与密码相同): <input name="pwd2" type="password" equalTo="#password"></p>
  <input class="submit" type="submit" value="提交">
</form>

<script type="text/javascript" src="jquery-1.11.1.js"></script>
<script type="text/javascript" src="jquery.validate.js"></script>
<script type="text/javascript">
  /*
  声明式验证:程序员只需要声明规则,可以自定义验证错误信息
   */
  $(function () {
    $('#myForm').validate({
      // 冒号前面对应name的值
      messages: {
        name: {
          required: '用户名是必须的',
          minlength: '用户名的最小长度是2'
        },
        pwd: {
          required: '密码是必须的',
          minlength: '密码的最小长度是6',
          maxlength: '密码的最大长度是8'
        },
        pwd2: {
          equalTo: '确认密码必须与密码相同'
        }
      }
    })
  })
</script>
</body>
</html>

标签:jQuery,插件,用户名,name,minlength,密码,validation
From: https://www.cnblogs.com/chuixulvcao/p/17058609.html

相关文章

  • IntelliJ插件笔记(二) 运行插件---添加Actions
    本文内容主要流程按照官网手册展开,也是较为准确的翻译。原文可见:CreatingActions|IntelliJPlatformPluginSDK(jetbrains.com)Actions插件可以在IDE的菜单或者工具......
  • maven flatten-maven-plugin 插件简单说明
    mavenflatten-maven-plugin是一个比较有意思的项目,核心是对于我们发布的包提供一些简洁清晰的使用,去除掉哪些没用的(比如父pom信息,profile信息。。。)参考使用maven......
  • jQuery(window.onload与$(document).ready())
    视频<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>window.onload与$(document).ready()</title></head><body><h1>测试window.onload......
  • jQuery多库共存
    视频<!DOCTYPEhtml><html><head><metacharset="UTF-8"><title>26_多库共存</title><styletype="text/css">*{margin:0px;}.div1......
  • React:开发者工具谷歌插件下载安装
    React:开发者工具谷歌插件最近学习前端react主要是想大概浏览一下,这里提供尚硅谷的是视屏资料中的谷歌插件的下载。(如有侵权联系删除)这里提供我的下载地址,其中除了插件,还有......
  • jQuery(自定义动画/导航动态显示效果)
    视频自定义动画<!DOCTYPEhtml><html><head><metacharset="UTF-8"><title>24_自定义动画</title><styletype="text/css">*{margin:0px;......
  • Kong网关安装自定义插件
    安装自定义插件需要注意kong网关的版本要求!! 下面以安装Skywalking插件为例,要求Kong网关是2.2及以上版本,https://github.com/apache/skywalking-kong一、下载Skywalking......
  • 生成二维码插件&用法
        1)vue-qrcode:     git地址:https://github.com/fengyuanchen/vue-qrcode     用法:        安装依赖:npminstallqrcode......
  • 前端打印插件jqprint的使用
    1、下载地址https://webscripts.softpedia.com/script/Modules/jQuery-Plugins/jqPrint-68448.html2、使用jqprint必须在使用引用插件之前加上jquery-migrate-1.2.1.min.j......
  • Vue3 (Vscode插件)
    前端开发的编辑器有很多种如DW,hubilder,WebStorm,sublime,vscode,等等。​​Vue3+vite+Ts+pinia+实战+源码+全栈_哔哩哔哩_bilibili​​ 视频教程随着VsCode开......