Validating date server side in php

Validating date server side in php

Call the validation from your JForm Field The last step in the validation process is to tell your form field which validation rule to use. Just add the reference of the rule name to the Jform XML for the input element: The important part of that is the validate="date" part.Unlike client-side validation, the validation uses html attributes to do its validation.There is the attribute required ("true" or "required") which makes a field required and the attribute validate with a joomla or custom rule value. field in a joomla form xml You can find the specific implementation of these rules in /libraries/joomla/form/- validation begins in the function validate(), moves to validate Field(), which then calls the respective validation functions of /libraries/joomla/form/rule/*Its very easy to add custom validation rules to your form elements.For an integer rule, the entire class looks like this: But often times you want a slightly more complex validation rule, to do this its easier to override the test() method, providing your own implementation and ignoring the regex entirely.For example, to test the format of a date: Note: The test() method already exists in the JForm Rule class, so here you are just extending the existing method.

For date.php, the class name should be JForm Rule Date.For integer you would have integer.php, and JForm Rule Integer.Use a Regex, or override the test function There's two ways to write the validator.The first and possibly easier is to simply override the $regex property of the JForm Rule class.You can easily extend the JForm Rule class to do this.

validating date server side in php-41validating date server side in php-26validating date server side in php-36

Join our conversation (2 Comments).
Click Here To Leave Your Comment Validating date server side in php.


Leave a Reply

Your email address will not be published. Required fields are marked *