Commit d01d8ada by wangzhihui

新增招聘添加校验

1 parent 81bf4392
...@@ -36,6 +36,10 @@ const VALIDATION_CONFIG = { ...@@ -36,6 +36,10 @@ const VALIDATION_CONFIG = {
} }
} }
// 详细地址:仅支持大小写字母、数字、中文及 、,/[]【】(提交时校验)
const ADDRESS_DETAIL_ALLOWED_REG = /^[a-zA-Z0-9\u4e00-\u9fa5、,\/\[\]【】]*$/
const ADDRESS_DETAIL_FORMAT_TIP = '详细地址仅支持大小写字母、数字、中文及、,/[]【】符号'
Page({ Page({
data: { data: {
IMG_URL, IMG_URL,
...@@ -212,7 +216,7 @@ Page({ ...@@ -212,7 +216,7 @@ Page({
// 详细地址输入(未创建系统门店时) // 详细地址输入(未创建系统门店时)
onAddressDetailInput(e) { onAddressDetailInput(e) {
const value = e.detail.value.trim().substring(0, 60) const value = e.detail.value.substring(0, 60)
const formList = this.data.formList const formList = this.data.formList
formList[FORM_FIELDS.ADDRESS_DETAIL].value = value formList[FORM_FIELDS.ADDRESS_DETAIL].value = value
formList[FORM_FIELDS.ADDRESS_DETAIL].displayValue = value formList[FORM_FIELDS.ADDRESS_DETAIL].displayValue = value
...@@ -595,13 +599,18 @@ Page({ ...@@ -595,13 +599,18 @@ Page({
}, },
// 表单验证 // 表单验证
validateForm() { validateForm() {
const { formList } = this.data const { formList, bySystemMerchant } = this.data
for (let [index, config] of Object.entries(VALIDATION_CONFIG)) { for (let [index, config] of Object.entries(VALIDATION_CONFIG)) {
if (config.required && !formList[index].value) { if (config.required && !formList[index].value) {
wx.showToast({ title: config.tip, icon: 'none', duration: 2000 }) wx.showToast({ title: config.tip, icon: 'none', duration: 2000 })
return false return false
} }
} }
const addressDetail = formList[FORM_FIELDS.ADDRESS_DETAIL].value || ''
if (bySystemMerchant && addressDetail && !ADDRESS_DETAIL_ALLOWED_REG.test(addressDetail)) {
wx.showToast({ title: ADDRESS_DETAIL_FORMAT_TIP, icon: 'none', duration: 2000 })
return false
}
return true return true
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!