amis2/examples/components/Form/Validation.jsx

112 lines
2.3 KiB
React
Raw Normal View History

2019-04-30 11:11:25 +08:00
export default {
2019-11-07 10:41:14 +08:00
title: '表单验证示例',
toolbar: "<a target='_blank' href='/docs/renderers/Form/FormItem'>文档</a>",
body: [
{
type: 'form',
autoFocus: false,
messages: {
validateFailed: '请仔细检查表单规则,部分表单项没通过验证'
},
title: '表单',
actions: [
{
type: 'submit',
label: '提交'
}
],
api: '/api/mock2/form/saveFormFailed?waitSeconds=2',
mode: 'horizontal',
body: [
2019-11-07 10:41:14 +08:00
{
type: 'input-text',
2019-11-07 10:41:14 +08:00
name: 'test',
label: '必填',
required: true
},
{
type: 'divider'
},
{
name: 'test1',
type: 'input-email',
2019-11-07 10:41:14 +08:00
label: 'Email'
},
{
type: 'divider'
},
{
name: 'url',
type: 'input-url',
label: 'URL'
2019-11-07 10:41:14 +08:00
},
{
type: 'divider'
},
{
name: 'num',
type: 'input-text',
2019-11-07 10:41:14 +08:00
label: '数字',
validations: 'isNumeric'
},
{
type: 'divider'
},
{
name: 'alpha',
type: 'input-text',
2019-11-07 10:41:14 +08:00
label: '字母或数字',
validations: 'isAlphanumeric'
},
{
type: 'divider'
},
{
name: 'int',
type: 'input-text',
2019-11-07 10:41:14 +08:00
label: '整形',
validations: 'isInt'
},
{
type: 'divider'
},
{
name: 'minLength',
type: 'input-text',
2019-11-07 10:41:14 +08:00
label: '长度限制',
validations: 'minLength:2,maxLength:10'
},
{
type: 'divider'
},
{
name: 'min',
type: 'input-text',
2019-11-07 10:41:14 +08:00
label: '数值限制',
validations: 'maximum:10,minimum:2'
},
{
type: 'divider'
},
{
name: 'reg',
type: 'input-text',
2019-11-07 10:41:14 +08:00
label: '正则',
validations: 'matchRegexp:/^abc/',
validationErrors: {
matchRegexp: '请输入abc开头的好么?'
}
},
{
type: 'divider'
},
{
name: 'test2',
type: 'input-text',
2019-11-07 10:41:14 +08:00
label: '服务端验证'
2019-04-30 11:11:25 +08:00
}
2019-11-07 10:41:14 +08:00
]
}
]
2019-04-30 11:11:25 +08:00
};