Commit c1fa22c1 authored by 王宝峰's avatar 王宝峰

留言咨询姓名正则匹配只能是汉字和字母二选一问题修复

parent 8ff77192
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
<uni-forms ref="form" :modelValue="personnel" label-position="top"> <uni-forms ref="form" :modelValue="personnel" label-position="top">
<uni-forms-item name="consultContent"> <uni-forms-item name="consultContent">
<uni-easyinput type="textarea" :inputBorder="false" v-model="personnel.consultContent" <uni-easyinput type="textarea" :inputBorder="false" v-model="personnel.consultContent"
placeholder="请输入留言内容" :trim="both" @focus="contentFlag = false" maxlength="140"/> placeholder="请输入留言内容" :trim="both" @focus="contentFlag = false" maxlength="140" />
<view v-if="contentFlag" class="contentVerify">内容不能为空格或回车</view> <view v-if="contentFlag" class="contentVerify">内容不能为空格或回车</view>
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="姓名" :required="true" name="nickName"> <uni-forms-item label="姓名" :required="true" name="nickName">
<uni-easyinput :inputBorder="false" type="text" v-model="personnel.nickName" <uni-easyinput :inputBorder="false" type="text" v-model="personnel.nickName" maxlength="16"
maxlength="16" placeholder="请输入姓名" /> placeholder="请输入姓名" />
</uni-forms-item> </uni-forms-item>
<uni-forms-item label="手机号" :required="true" name="phone"> <uni-forms-item label="手机号" :required="true" name="phone">
<uni-easyinput :inputBorder="false" type="text" v-model="personnel.phone" maxlength="11" <uni-easyinput :inputBorder="false" type="text" v-model="personnel.phone" maxlength="11"
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
contentFlag: false, contentFlag: false,
url: '', url: '',
personnel: { personnel: {
consultType:'', consultType: '',
consultContent: '', consultContent: '',
nickName: '', nickName: '',
phone: '', phone: '',
...@@ -88,12 +88,13 @@ ...@@ -88,12 +88,13 @@
{ {
validateFunction: function(rule, value, data, callback) { validateFunction: function(rule, value, data, callback) {
console.log("姓名--》", value) console.log("姓名--》", value)
// 只能输入字母或者汉字,二选一
let nameReg =/^[\u4E00-\u9FA5]{2,16}$|^[a-zA-Z]{2,16}$/ // let nameReg =/^[\u4E00-\u9FA5]{2,16}$|^[a-zA-Z]{2,16}$/
// let nameReg2 =// // 只能输入字母或者汉字,字母和汉字可以混一起
let nameReg = /^[a-zA-Z \u4E00-\u9FA5]{2,16}$/
if (!nameReg.test(value)) { if (!nameReg.test(value)) {
callback('姓名只能输入汉字或者大小写字母,请重新填写') callback('姓名只能输入汉字或者大小写字母,请重新填写')
} }
return true return true
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment