Home >Backend Development >PHP Tutorial >How to use joomla's built-in form validation function_PHP tutorial

How to use joomla's built-in form validation function_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-21 15:37:19921browse

Here's how to use it:
Enter the following code at the top of the page where you want to use the form function
JHTML::_('behavior.formvalidation');
Then add the following script to the page

Copy code The code is as follows:

> ;

Modify the code at the position of form
Copy the code The code is as follows:

After adding the above code, as long as class="required" is added to the input in the form, the verification function will take effect.
Joomla’s verification scripts are all implemented using classes, and the name of the class determines what verification method is used.
The most commonly used class="required" means required items
class="validate-email" means to verify email address
Verification methods can be used in combination. For example, if I want Email, it must meet the format. You can submit it by writing:
class="validate-email required"

Customized verification method:
Joomla verification function supports customization, and you can set uncommon verification rules.
For example, if I want to make a password item and a confirmation password item, the values ​​of the two input boxes must be equal before submission. You can add the following script
Copy code The code is as follows:

document.formvalidator.setHandler('passverify', function (value) { return ($('password').value == value); });
< ;input type="password" value="" class="validate-passverify" />

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321964.htmlTechArticleHere’s how to use it: Enter the following code JHTML at the top of the page where you want to use the form function::_( 'behavior.formvalidation'); Then add the following script to the page and copy the code...
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