当前位置:网站首页>Common verification rules of form components -1 (continuously updating ~)
Common verification rules of form components -1 (continuously updating ~)
2022-07-04 20:36:00 【51CTO】
Preface
I feel more and more deeply recently , It's about sharing often , Share your own pitfalls , Share your solutions , Share your experiences , It's very necessary . because , My first reaction when I encounter a problem is to see how others solve it , Someone must have the same idea , At this time, we all need to share very generously . therefore , In the future, I will try to summarize and share regularly , It's convenient for others and for yourself ~
Reference link
https://element.eleme.io/#/zh-CN/component/form
https://github.com/yiminghe/async-validator
Introduction to form verification
Purpose of use
On the premise of preventing users from making mistakes , Let users find and correct errors as early as possible .
Easy to use
Form Component provides the function of form validation , Just go through rules
Property to pass in the validation rules of the contract , And will Form-Item Of prop
Property is set to the field name to be verified .
< el - form : model = "ruleForm" : rules = "rules" ref = "ruleForm" label - width = "100px" class = "demo-ruleForm" >
< el - form - item label = " The name of the event " prop = "name" >
< el - input v - model = "ruleForm.name" > < /el-input>
< /el-form-item>
< el - form - item >
< el - button type = "primary" @ click = "submitForm('ruleForm')" > Create... Now < /el-button>
< el - button @ click = "resetForm('ruleForm')" > Reset < /el-button>
< /el-form-item>
< /el-form>
< script >
export default {
data() {
return {
ruleForm: {
name: '',
},
rules: {
name: [
{ required: true, message: ' Please enter the activity name ', trigger: 'blur' },
{ min: 3, max: 5, message: ' The length is in 3 To 5 Characters ', trigger: 'blur' }
],
}
};
},
methods: {
submitForm( formName) {
this. $refs[ formName]. validate(( valid) => {
if ( valid) {
alert( 'submit!');
} else {
console. log( 'error submit!!');
return false;
}
});
},
resetForm( formName) {
this. $refs[ formName]. resetFields();
}
}
}
< /script>
- 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.
Common field
required
Is it required , Used to verify whether the field content is empty ;
type
data type , Similar data format verification , The default is string, Common types are number
,boolean
,integer
,float
,array
,date
,email
etc. ;
pattern
Only when the field value matches the regular expression can it pass the validation ;
min
and max
about string And arrays ,min and max Represents the minimum and maximum length ; For numbers number Come on , Indicates the size of the limit value ;
trigger
Conditions that trigger validation ;
validator
You can customize the validation function for the specified field :function(rule, value, callback);
边栏推荐
- Installation and use of VMware Tools and open VM tools: solve the problems of incomplete screen and unable to transfer files of virtual machines
- 什么叫内卷?
- 实战模拟│JWT 登录认证
- 精选综述 | 用于白内障分级/分类的机器学习技术
- Kotlin inheritance
- Chrome development tool: what the hell is vmxxx file
- Development and construction of DFI ecological NFT mobile mining system
- What does the neural network Internet of things mean? Popular explanation
- [Beijing Xunwei] i.mx6ull development board porting Debian file system
- Kotlin cycle control
猜你喜欢
c# . Net MVC uses Baidu ueditor rich text box to upload files (pictures, videos, etc.)
B2B mall system development of electronic components: an example of enabling enterprises to build standardized purchase, sale and inventory processes
Dark horse programmer - software testing - 09 stage 2-linux and database -31-43 instructions issued by modifying the file permission letter, - find the link to modify the file, find the file command,
实战模拟│JWT 登录认证
上线首月,这家露营地游客好评率高达99.9%!他是怎么做到的?
Related concepts of federal learning and motivation (1)
FS8B711S14电动红酒开瓶器单片机IC方案开发专用集成IC
How to adapt your games to different sizes of mobile screen
Small hair cat Internet of things platform construction and application model
实战模拟│JWT 登录认证
随机推荐
九齐单片机NY8B062D单按键控制4种LED状态
水晶光电:长安深蓝SL03的AR-HUD产品由公司供应
PHP pseudo original API docking method
Free soldier
Hash哈希竞猜游戏系统开发如何开发丨哈希竞猜游戏系统开发(多套案例)
Abc229 summary (connected component count of the longest continuous character graph in the interval)
Decryption function calculates "task state and lifecycle management" of asynchronous task capability
凌云出海记 | 文华在线&华为云:打造非洲智慧教学新方案
应用实践 | 蜀海供应链基于 Apache Doris 的数据中台建设
更强的 JsonPath 兼容性及性能测试之2022版(Snack3,Fastjson2,jayway.jsonpath)
Application practice | Shuhai supply chain construction of data center based on Apache Doris
[problem] Druid reports exception SQL injection violation, part always true condition not allow solution
How is the entered query SQL statement executed?
Huawei Nova 10 series supports the application security detection function to build a strong mobile security firewall
Template_ Judging prime_ Square root / six prime method
HMM hidden Markov model and code implementation
Huawei cloud store homepage banner resource bit application
YOLOv5s-ShuffleNetV2
What financial products can you buy with a deposit of 100000 yuan?
Offset function and windowing function