-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·45 lines (42 loc) · 938 Bytes
/
index.js
File metadata and controls
executable file
·45 lines (42 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const WeValidator = require('../../js/we-validator')
Page({
onReady() {
this.initValidator()
},
onSubmitForm(e) {
let { value } = e.detail
console.log(value)
if (!this.validatorInstance.checkData(value)) return
// 开始提交表单
// wx.request
console.log('submiting')
},
initValidator() {
this.validatorInstance = new WeValidator({
rules: {
username: {
required: true
},
phoneno: {
required: true,
mobile: true
},
str: {
length: 3
},
},
messages: {
username: {
required: '请输入用户名'
},
phoneno: {
required: '请输入手机号',
mobile: '手机号格式不正确'
},
str: {
length: '请输入长度为3的字符串'
},
},
})
},
})