Jquery.Validate基本使用方法及注意事项
type
status
date
slug
summary
tags
category
icon
password
order
jquery.validate官方文档:点此打开
jquery.validate.unobtrusive文档:点此打开
首先四个引入
然后验证方式三种:
第一种: 使用class="{}"的方式,必须引入包:jquery.metadata.js
例如:
第二种: 写在标签的多个属性上
例如:
补充:
  • data-val-required="message". Shows the message when the element has no value
  • data-val-length="message" + data-val-length-min="min length" and/or data-val-length-max="max length". Shows the message if the contents of the element are too long or too short
  • data-val-number="message" or data-val-date="message". Shows the message when the value of the element is not of the right type. Other types: data-val-creditcard, data-val-digits, data-val-email, data-val-ur
  • data-val-regex="message" + data-val-regex-pattern="^pattern$". Shows the message if the value of the element does not match the pattern
  • data-val-equalto="message" + data-val-equalto-other="jQuery selector". Shows the message if the contents of the element are not the same as the contents of the element selected by the jQuery selector (usually "#someid")
  • data-val-range="message" + data-val-range-min="min" + data-val-range-max="max". Shows the message if the contents of the element are not in the range. Specify both min and max!
第三种: JS设置
例如
最后,说下配合jquery.Form 提交表单
这种方式,如果你引用了jquery.validate.unobtrusive.js是无效的,等于你白配置,参数没设置进去一样
// jQuery Unobtrusive Validation 只能这样设置才有效
最后最后,可以稍微封装一下方便多处使用
 
.Net Core Mvc中Url.Action的一个坑完整Debian7配置LAMP(Apache/MySQL/PHP)环境及搭建建站