One of the powerful features of yii2 is its Form component, which is both convenient and safe. Some friends feel that after using Yii for a while, it seems to be nothing but "difficult to understand" than TP. The leader arranged for a registration function, but this guy used Baidu's various good form styles, and Baidu's validate verification. I really felt sorry for this guy. Of course, without further ado, our focus is to use ActiveForm and how to implement custom validation rules. Let’s talk about the scenario first: Conditions: ①. There are two fields, A and B. ②. A has two values, 1 and 2. The requirement is: when the value of A selected by the user is equal to 1, the value of B must Fill in, when the value of A is equal to 2, it doesn't matter if the value of B is not written. Among them, A is required. Let’s take a look at how to implement it using the rules that come with Yii2. First, add the following rule /*** @inheritdoc*/ to its associated model. public function rules() { return [ [['B'], 'requiredByASpecial'], ];
1.Rules in yii2 Detailed explanation of custom verification rules rules card yii rules techrules
Introduction: rules:yii2 Detailed explanation of custom validation rules in rules: One of the powerful features of yii2 is its Form component, which is both convenient and safe. Some friends feel that after using Yii for a while, it seems to be nothing but "difficult to understand" than TP. The leader arranged for a registration function, but this guy used Baidu's various good form styles, and Baidu's validate verification. I really felt sorry for this guy. Of course, without further ado, our focus is to use ActiveForm and how to implement custom validation rules. Let’s talk about the scenario first: Conditions: ①. There are two fields, A and B
2.Detailed explanation of the use of jQuery validate verification plug-in_jquery
Introduction: This article mainly introduces the usage of jQuery validate verification plug-in in detail. Validate is a lightweight verification plug-in based on jQuery. It supports the verification of input, select and textarea. If you are interested Friends, you can refer to
3.Detailed explanation of knowledge points based on jQuery.Validate verification library_jquery
Introduction: This article introduces a detailed explanation of the knowledge points of the jQuery.Validate verification library. Friends in need can refer to
4.Introduction to the use of jQuery.Validate verification library_jquery
Introduction: This article introduces the use of jQuery.Validate verification library. Friends in need can refer to
5.Small example of jquery plug-in validate_jquery
Introduction: jquery plug-in A small example of validate verification
6.jQuery Validate validation framework classic collection_jquery
Introduction: This article is a small I have compiled a complete jquery validate verification framework to share with you. This article is very detailed. Friends who are interested should take a look.
7.jquery determines whether to enter a password twice Equality_jquery
#Introduction: This article introduces the Jquery framework easyui to determine whether the password entered twice is equal, and uses jQuery.validate to verify whether the two passwords in the form are consistent. Friends who need it can refer to
##8.CKEditor cannot verify the solution (js verification + jQuery Validate verification)_jquery
Introduction: This article mainly introduces the CKEditor unverifiable solution and the jQuery Validate verification framework in detail. Interested friends can refer to it
[Related Q&A recommendations]:
javascript - vee-validate cannot be entered after verification is not empty
javascript - How to perform jQuery Validate on ckeditor Validation
javascript - A series of questions about form validation validate
The above is the detailed content of Recommended courses on Validate verification. For more information, please follow other related articles on the PHP Chinese website!