The verification of layui form element only needs to add lay-verify to the element, and layui provides the following values.
1 2 3 4 5 6 7 8 |
|
Supports verification of multiple rules at the same time, format: lay-verify=”Verify A|Verify B”
如:lay-verify=”required|phone|number”
In addition, in addition to our built-in verification rules, you can also set any value for him, such as lay-verify=”pass”, then you need to use the form.verify() method to define a verification rule for pass
Example:
1 2 3 4 5 6 |
|
When you fill in an illegal email, you will be prompted with a smiley face icon when you click Submit, which is great!
Custom check:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
After you customize the verification rules similar to the above, you only need to assign the key to the lay-verify attribute of the input box:
1 2 |
|
Reposted from https://www.jb51.net/article/169250.htm