Home > Article > Web Front-end > How vue.js determines whether the input is a number
Vue.js method to determine whether the input is a number: Use regular expressions to determine whether the input value is a number. The code is [this.$message({type: 'warning',message: 'Please enter Number',duration: 10000})].
【Recommended related articles: vue.js】
vue.js method to determine whether the input is a number:
Regular expressions can be used in vue to determine whether the input value is a number:
var numReg = /^[0-9]*$/ var numRe = new RegExp(numReg) if (!numRe.test(number)) { this.$message({ type: 'warning', message: '请输入数字 ', duration: 10000, showClose: true, }) return false }
Regular expression /^[0-9]*$/ means that only numbers can be entered:
^
: represents the beginning of the regular expression ,
$
represents the end of the regular expression,
*
represents matching 0-- Infinite,
[]
represents the relationship between or
Related free learning recommendations: JavaScript(Video)
The above is the detailed content of How vue.js determines whether the input is a number. For more information, please follow other related articles on the PHP Chinese website!