Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
data-table
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2022-12-22 13:18:18 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c4e263d833fbbe57478fd1cf8977f5d1c301b68e
c4e263d8
1 parent
fa015b0b
邮箱控件校验调整
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
8 deletions
src/components/EmailField/index.vue
src/components/NumberField/index.vue
src/components/EmailField/index.vue
View file @
c4e263d
<!--
* @Date: 2022-08-29 14:31:20
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-1
1-21 16:08:20
* @LastEditTime: 2022-1
2-22 13:17:34
* @FilePath: /data-table/src/components/EmailField/index.vue
* @Description: 邮箱输入框
-->
...
...
@@ -28,15 +28,25 @@ const props = defineProps({
item: Object,
});
const required = props.item.component_props.required;
const validator = (val) => {
if (!props.item.component_props.required) {
// 非必填
return true;
if (required && !val) {
return false;
} else if (val && !/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/.test(val)) {
return false;
} else {
return /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/.test(val);
return true;
}
};
// 错误提示文案
const validatorMessage = (val, rule) => {
if (required && !val) {
return "必填项不能为空";
} else if (val && !/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/.test(val)) { // 小于最小值
return "请输入正确邮箱";
}
};
const rules = [{ validator, message:
"请输入正确邮箱"
}];
const rules = [{ validator, message:
validatorMessage
}];
</script>
<style lang="less" scoped>
...
...
src/components/NumberField/index.vue
View file @
c4e263d
<!--
* @Date: 2022-09-14 14:44:30
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2022-12-22 1
1:28:05
* @LastEditTime: 2022-12-22 1
3:15:32
* @FilePath: /data-table/src/components/NumberField/index.vue
* @Description: 数字输入框
-->
...
...
@@ -148,7 +148,7 @@ const validator = (val) => {
// 错误提示文案
const validatorMessage = (val, rule) => {
if (required && !val) {
return "
输入
不能为空";
return "
必填项
不能为空";
} else if (val && min && (val < min)) { // 小于最小值
return "最小值为" + min;
} else if (val && max && (val > max)) { // 大于最大值
...
...
Please
register
or
login
to post a comment