input中允许输入年或年月或年月,即 2023 或 2023-09 或 2023-09-11
pattern:/( ^[ 1 -2] [ 0 -9] [ 0 -9] [ 0 -9] -( [ 1 ] [ 0 -2] | 0 ?[ 1 -9] ) -( [ 12 ] [ 0 -9] | 3 [ 01] | 0 ?[ 1 -9] ) $) | ( ^[ 1 -2] [ 0 -9] [ 0 -9] [ 0 -9] -( [ 1 ] [ 0 -2] | 0 ?[ 1 -9] ) $) | ( ^[ 1 -2] [ 0 -9] [ 0 -9] [ 0 -9] $) /
只允许填入英文,数字,下划线和 -
pattern: /^[ A-Za-z0-9_-] +$/
合法金额 xx.ss
pattern: /^( \ d+) (( ?:\ .\ d+) ?) $/,
该数字是否大于0的数字(常用于【排序】字段)
pattern: /^[ 1 -9] \ d*$/,
校验数组
< template> < el-form inline-message :model= "form" :rules= "rules" > < el-descriptions-item v-else label = "文件权限:" :span= "1" > < el-form-item prop = "checkList" > < el-checkbox v-model= "form.fileBrowse" false-lable= "0" true-label= "1" > 浏览< /el-checkbox> < el-checkbox v-model= "form.fileDownload" false-lable= "0" true-label= "1" > 下载< /el-checkbox> < /el-form-item> < /el-descriptions-item> < el-form>
< /template> < script> < script>
export default { data ( ) { var validatePremessions = ( rule, value, callback) = > { let result = validatenPremession( this.form.fileBrowse,this.form.fileDownload) if ( result == false ) { callback( new Error( '请至少选择一种权限' )) } else { callback( ) } } return { form: { borrowType: '0' ,fileBrowse: '0' ,fileDownload: '0' ,expectReturnTime: '' ,borrowDays: null,} ,rules: { checkList: [ { required: true, validator: validatePremessions, trigger: 'blur' } ,] ,} ,} ,
}
长度不少于8个字符,需包含大小写英文、数字、特殊字符(!@#$%&?)
pattern: /^( ?= .*[ A-Z] ) ( ?= .*[ a-z] ) ( ?= .*\ d) ( ?= .*[ ! @