search
HomeWeChat AppletMini Program DevelopmentWeChat applet implements simple input regular expression verification function

WeChat applet implements simple input regular expression verification function

Jun 22, 2018 pm 05:31 PM
inputWeChat appletregular expressionverify

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:&#39;&#39;
  },
  check:function(e){
    var regLowerCase=new RegExp(&#39;[a-z]&#39;,&#39;g&#39;);//判断用户输入的是否为小写字母
    var regCapitalLetter=new RegExp(&#39;[A-Z]&#39;,&#39;g&#39;);//判断用户输入的是否为大写字母
    var regNum=new RegExp(&#39;[0-9]&#39;,&#39;g&#39;);//判断用户输入的是否为数字
    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:&#39;您输入的是小写字母&#39;
      })
    }else if(rsCapitalLetter){
      this.setData({
        result:&#39;您输入的是大写字母&#39;
      })
    }else if(rsNum){
      this.setData({
        result:&#39;您输入的是数字&#39;
      })
    }else{
      this.setData({
        result:&#39;&#39;
      })
    }
  }
})

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment