mirror of https://github.com/layui/layui
优化 form 中内置验证规则的逗号风格
parent
d3ff3dcd12
commit
68a9ab7999
|
@ -16,36 +16,37 @@ layui.define(['lay', 'layer', 'util'], function(exports){
|
||||||
|
|
||||||
var Form = function(){
|
var Form = function(){
|
||||||
this.config = {
|
this.config = {
|
||||||
|
// 内置的验证规则
|
||||||
verify: {
|
verify: {
|
||||||
required: [
|
required: [
|
||||||
/[\S]+/
|
/[\S]+/,
|
||||||
,'必填项不能为空'
|
'必填项不能为空'
|
||||||
]
|
],
|
||||||
,phone: [
|
phone: [
|
||||||
/^1\d{10}$/
|
/^1\d{10}$/,
|
||||||
,'请输入正确的手机号'
|
'请输入正确的手机号'
|
||||||
]
|
],
|
||||||
,email: [
|
email: [
|
||||||
/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/
|
/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/,
|
||||||
,'邮箱格式不正确'
|
'邮箱格式不正确'
|
||||||
]
|
],
|
||||||
,url: [
|
url: [
|
||||||
/^(#|(http(s?)):\/\/|\/\/)[^\s]+\.[^\s]+$/
|
/^(#|(http(s?)):\/\/|\/\/)[^\s]+\.[^\s]+$/,
|
||||||
,'链接格式不正确'
|
'链接格式不正确'
|
||||||
]
|
],
|
||||||
,number: function(value){
|
number: function(value){
|
||||||
if(!value || isNaN(value)) return '只能填写数字'
|
if(!value || isNaN(value)) return '只能填写数字'
|
||||||
}
|
},
|
||||||
,date: [
|
date: [
|
||||||
/^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/
|
/^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/,
|
||||||
,'日期格式不正确'
|
'日期格式不正确'
|
||||||
|
],
|
||||||
|
identity: [
|
||||||
|
/(^\d{15}$)|(^\d{17}(x|X|\d)$)/,
|
||||||
|
'请输入正确的身份证号'
|
||||||
]
|
]
|
||||||
,identity: [
|
},
|
||||||
/(^\d{15}$)|(^\d{17}(x|X|\d)$)/
|
autocomplete: null // 全局 autocomplete 状态。 null 表示不干预
|
||||||
,'请输入正确的身份证号'
|
|
||||||
]
|
|
||||||
}
|
|
||||||
,autocomplete: null // 全局 autocomplete 状态。null 表示不干预
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue