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,
2020 year Java industry , General analysis of market environment and position Old farmer's tears : Nine iron rules of mixed workplace Database design use MySQL Processing 100 million level data 【 course 】 How to modify routing table ?vue project main.js usage method 【Java Details of knowledge points 3】 Serializable and Deserialize Renren from the perspective of Technology , Internet Marketing Python list , Yuanzu Aerial photography : Tesla Shanghai factory Model Y A large number of people have been offline