Implementation method of iview custom verification keyword input box
This time I will bring you the implementation method of iview custom verification keyword input box. What are the precautions for implementing iview custom verification keyword input box. The following is a practical case. Let’s take a look. .
1. Verification requirements
Corresponding to the configured keyword input box, the verification requirements are as follows:
1. Total word count It cannot exceed 7000;
2. Remove the configured keyword special symbols, and the number of keyword groups obtained cannot exceed 300; (such as: aaa&(bbb|ccc)|(!ddd|eee)), remove the special symbols symbols, there are 5 groups)
3. The length of a single keyword cannot exceed 20; (such as: aaaaa&(bbb|ccc)), if the length of aaaaa exceeds 20, it will prompt)
2. Solution
Add a prop attribute to the FormItem
corresponding to the keyword input as a verification field Use; note that the FormItem is included in the Form;
Add rules verification in the form form
Because iview has Empty and total length can be directly defined Verification rules, so I only write the other two here. The code is as follows:
//高级配置验证 validateAdvancedFormItem: { name: [ {required: true, message: '任务名称不能为空', trigger: 'blur'}, {type: 'string', max: 20, message: '不能超过20个字符', trigger: 'blur'}, {validator: validNameExist, trigger: 'blur'} ], groupId: [ {type: 'string', required: true, message: '请选择任务分组', trigger: 'change'} ], keywords: [ {required: true, message: '关键词不能为空', trigger: 'blur'}, {type: 'string', max: 7000, message: '不能超过7000个字符', trigger: 'blur'}, {validator: validKeyWordsRule, trigger: 'blur'} ], /* chooseSiteGroupList: [//todo 暂时注释掉网站分组 { required: true, type: 'array', min: 1, message: '请选择网站分组', trigger: 'change' }, ],*/ chooseInfoTypeList: [ {required: true, type: 'array', min: 1, message: '请选择信息类型', trigger: 'change'}, ], warnNum: [ {required: true, message: '请填写预警增量'}, ], warnUserList: [ {required: true, type: 'array', message: '请选择预警人员', validator: validatewarnUser, trigger: 'change'}, ], },
Custom verification rule method:
//验证高级配置关键词 规则 const validKeyWordsRule = (rule, value, callback) => { var isExceedTwitenty = this.getAdvancedKeyWords(); var isExceedThreeHundreand = this.getAdvancedKeyWords(); if(isExceedTwitenty == 1) { callback(new Error('配置单个关键词长度不能超过20')) } else if(isExceedThreeHundreand == 2) { callback(new Error('配置关键词个数不能超过300')) } else { callback(); } }; //处理关键词 getAdvancedKeyWords: function () { var flag = -1; if(this.dailyTaskItem.keywords != '' && this.dailyTaskItem.keywords.trim() != '') { //判断单个配置的关键词长度是否大于20 var str = ''; for (var i = 0; i 20) { flag = 1; break } } } //.关键词一共300个 if(resultArr.length > 300) { flag = 2; } } return flag; },
Believe it After reading the case in this article, you have mastered the method. For more exciting information, please pay attention to other related articles on the PHP Chinese website!
Recommended reading:
Detailed explanation of the steps to convert non-array objects to arrays (with code)
How to fix v-show not working Processing
Vue globally introduces bass.scss implementation steps
The above is the detailed content of Implementation method of iview custom verification keyword input box. For more information, please follow other related articles on the PHP Chinese website!

Introduction I know you may find it strange, what exactly does JavaScript, C and browser have to do? They seem to be unrelated, but in fact, they play a very important role in modern web development. Today we will discuss the close connection between these three. Through this article, you will learn how JavaScript runs in the browser, the role of C in the browser engine, and how they work together to drive rendering and interaction of web pages. We all know the relationship between JavaScript and browser. JavaScript is the core language of front-end development. It runs directly in the browser, making web pages vivid and interesting. Have you ever wondered why JavaScr

Node.js excels at efficient I/O, largely thanks to streams. Streams process data incrementally, avoiding memory overload—ideal for large files, network tasks, and real-time applications. Combining streams with TypeScript's type safety creates a powe

The differences in performance and efficiency between Python and JavaScript are mainly reflected in: 1) As an interpreted language, Python runs slowly but has high development efficiency and is suitable for rapid prototype development; 2) JavaScript is limited to single thread in the browser, but multi-threading and asynchronous I/O can be used to improve performance in Node.js, and both have advantages in actual projects.

JavaScript originated in 1995 and was created by Brandon Ike, and realized the language into C. 1.C language provides high performance and system-level programming capabilities for JavaScript. 2. JavaScript's memory management and performance optimization rely on C language. 3. The cross-platform feature of C language helps JavaScript run efficiently on different operating systems.

JavaScript runs in browsers and Node.js environments and relies on the JavaScript engine to parse and execute code. 1) Generate abstract syntax tree (AST) in the parsing stage; 2) convert AST into bytecode or machine code in the compilation stage; 3) execute the compiled code in the execution stage.

The future trends of Python and JavaScript include: 1. Python will consolidate its position in the fields of scientific computing and AI, 2. JavaScript will promote the development of web technology, 3. Cross-platform development will become a hot topic, and 4. Performance optimization will be the focus. Both will continue to expand application scenarios in their respective fields and make more breakthroughs in performance.

Both Python and JavaScript's choices in development environments are important. 1) Python's development environment includes PyCharm, JupyterNotebook and Anaconda, which are suitable for data science and rapid prototyping. 2) The development environment of JavaScript includes Node.js, VSCode and Webpack, which are suitable for front-end and back-end development. Choosing the right tools according to project needs can improve development efficiency and project success rate.

Yes, the engine core of JavaScript is written in C. 1) The C language provides efficient performance and underlying control, which is suitable for the development of JavaScript engine. 2) Taking the V8 engine as an example, its core is written in C, combining the efficiency and object-oriented characteristics of C. 3) The working principle of the JavaScript engine includes parsing, compiling and execution, and the C language plays a key role in these processes.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

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.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version
Chinese version, very easy to use

Notepad++7.3.1
Easy-to-use and free code editor

Dreamweaver Mac version
Visual web development tools
