WeChat applet implements simple input Regular Expression verification function example, input Regular Expression

Source: Internet
Author: User

Example of the simple input Regular Expression verification function implemented by the Applet: input Regular Expression

This example describes how to implement simple input Regular Expression verification in a applet. We will share this with you for your reference. The details are as follows:

1. Effect display

2. Key code

Index. wxml File

<Input placeholder = "input content" bindinput = "check"> </input> <view> input result: {result }}</view>

Index. js File

Page ({data: {result: ''}, check: function (e) {var regLowerCase = new RegExp ('[a-z]', 'G '); // determine whether the user input is a lowercase letter var regCapitalLetter = new RegExp ('[A-Z]', 'G '); // determine whether the input is an uppercase letter var regNum = new RegExp ('[0-9]', 'G '); // determine whether the user inputs a number var rslowercase1_reglowercase.exe c (e. detail. value); var rsCapitalLetter=regCapitalLetter.exe c (e. detail. value); var rsnum1_regnum.exe c (e. detail. value); if (rsLowerCase) {this. setData ({result: 'The lower-case letter you entered '})} else if (rsCapitalLetter) {this. setData ({result: 'Your input is an uppercase letter '})} else if (rsNum) {this. setData ({result: 'Number you entered '})} else {this. setData ({result :''})}}})

3. Click here for the complete instance codeDownload from this site.

PS: here we will provide two very convenient Regular Expression tools for your reference:

JavaScript Regular Expression online testing tool:
Http://tools.jb51.net/regex/javascript

Regular Expression generation tool:
Http://tools.jb51.net/regex/create_reg

I hope this article will help you develop small programs.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.