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" />
http://www.bkjia.com/PHPjc/321964.htmlwww.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...