This article mainly introduces the WeChat applet to implement simple input regular expression verification function, and analyzes the WeChat applet input component event binding and regular expression verification related operation skills in the form of examples. Friends who need it can refer to it
The example in this article describes the implementation of simple input regular expression verification function by WeChat applet. Share it with everyone for your reference, the details are as follows:
1. Effect display
2. Key code
index.wxml file
<input placeholder="输入内容" bindinput="check"></input> <view>输入结果:{{result}}</view>
index.js file
Page({ data:{ result:'' }, check:function(e){ var regLowerCase=new RegExp('[a-z]','g');//判断用户输入的是否为小写字母 var regCapitalLetter=new RegExp('[A-Z]','g');//判断用户输入的是否为大写字母 var regNum=new RegExp('[0-9]','g');//判断用户输入的是否为数字 var rsLowerCase=regLowerCase.exec(e.detail.value); var rsCapitalLetter=regCapitalLetter.exec(e.detail.value); var rsNum=regNum.exec(e.detail.value); if(rsLowerCase){ this.setData({ result:'您输入的是小写字母' }) }else if(rsCapitalLetter){ this.setData({ result:'您输入的是大写字母' }) }else if(rsNum){ this.setData({ result:'您输入的是数字' }) }else{ this.setData({ result:'' }) } } })
The above is the entire content of this article, I hope it will be helpful to Everyone’s learning is helpful. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
Introduction to Gesture Unlocking in the Development of WeChat Mini Programs
The Snake Realized by WeChat Mini Programs Game【With source code】
The above is the detailed content of WeChat applet implements simple input regular expression verification function. For more information, please follow other related articles on the PHP Chinese website!