Method 1 : It is realized by regular expression
<template> <div> <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label
-width="100px" class="demo-ruleForm"> <el-row> <el-col :span="6"> <el-form-item
label=" amount of money " prop="money"> <el-input v-model.number="ruleForm.money"></el-input> <
/el-form-item> </el-col> </el-row> <el-row> <el-col :span="6" style=
"text-align:center"> <el-form-item> <el-button type="primary" @click=
"submitForm('ruleForm')"> Submit </el-button> </el-form-item> </el-col> </el-row> </el
-form> </div> </template> <script> export default { data() { return { ruleForm:
{ money:'', }, rules: { money:[ { required: true, message: ' Amount cannot be blank '}, { type:
'number', message: ' Amount must be numeric '}, // And does not include decimals { pattern:
/^([0-9]|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])$/, message: ' The scope is 0-255',trigger: 'blur'}
/* Range 0-255 analysis : 0-9: [0-9] 10-99: [1-9]\d 100-199: 1\d\d 200-249: 2[0-4]\d
250-255: 25[0-5] */ ], } }; }, methods: { submitForm(formName) { this.$refs[
formName].validate((valid) => { if (valid) { alert(' success '); } else { return false;
} }); }, } } </script>
supplement : Regular expression related knowledge points

Method 2 : User defined verification rules
<template> <div> <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label
-width="100px" class="demo-ruleForm"> <el-row> <el-col :span="6"> <el-form-item
label=" amount of money " prop="money"> <el-input v-model.number="ruleForm.money"></el-input> <
/el-form-item> </el-col> </el-row> <el-row> <el-col :span="6" style=
"text-align:center"> <el-form-item> <el-button type="primary" @click=
"submitForm('ruleForm')"> Submit </el-button> </el-form-item> </el-col> </el-row> </el
-form> </div> </template> <script> export default { data() { var checkMoney = (
rule, value, callback) => { if (!value) { return callback(new Error(' Amount cannot be blank '));
} setTimeout(() => { if (!Number.isInteger(value)) { callback(new Error(' Please enter a numeric value '
)); } else { if (value < 0) { callback(new Error(' The scope is 0-255')); } else if(value >
255){ callback(new Error(' The scope is 0-255')); }else { callback(); } } }, 100); };
return { ruleForm: { money:'', }, rules: { money:[ { validator: checkMoney,
trigger: 'blur' } ], } }; }, methods: { submitForm(formName) { this.$refs[
formName].validate((valid) => { if (valid) { alert(' success '); } else { return false;
} }); }, } } </script>
effect

Technology
©2019-2020 Toolsou All rights reserved,
Non preemptive static priority scheduling algorithm for operating system (C language )Go Language learning notes (GUI programming )XCTF Attack and defense world web Advanced practice _ 2_lottery What's the difference between computer major and training background ?python realization vlookup_ Dry goods I : Why python It's inside vlookup Bubble sort primary springboot2 Separation of front and rear platforms ,token Put in header Pit for verification Python Case conversion of letters ( Two methods )javascript event ( Detailed explanation of zero basis )Unity2019 UIElement note ( ten ) Simple exercise 2