|
@@ -551,6 +551,18 @@ Page({
|
|
|
showClass: false
|
|
|
})
|
|
|
},
|
|
|
+ messageName(value: string) {
|
|
|
+ const nameReg = /^[\u4E00-\u9FA5]+$/
|
|
|
+ if (!value) {
|
|
|
+ return '请输入学生姓名';
|
|
|
+ } else if (!nameReg.test(value)) {
|
|
|
+ return '学生姓名必须为中文';
|
|
|
+ } else if (value.length < 2 || value.length > 14) {
|
|
|
+ return '学生姓名必须为2~14个字';
|
|
|
+ } else {
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+ },
|
|
|
/** 最终提交 */
|
|
|
async onSubmit() {
|
|
|
try {
|
|
@@ -562,10 +574,10 @@ Page({
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- if (!params.name) {
|
|
|
+ const mesName = this.messageName(params.name)
|
|
|
+ if (mesName) {
|
|
|
wx.showToast({
|
|
|
- title: '请输入学生姓名',
|
|
|
+ title: mesName,
|
|
|
icon: "none"
|
|
|
})
|
|
|
return
|