Download the PHP package phpgt/domvalidation without Composer
On this page you can find all versions of the php package phpgt/domvalidation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phpgt/domvalidation
More information about phpgt/domvalidation
Files in phpgt/domvalidation
Package domvalidation
Short Description Server side form validation using web standards.
License MIT
Informations about the package domvalidation
Server side form validation using web standards.
HTML forms can be annotated in such a way that the individual input elements can describe their own validation rules. The simplest annotation is the required
attribute, which can be specified on input elements to indicate that the form is not to be submitted until a value is given.
This repository performs W3C form validation for projects that have a server-side DOM, such as within WebEngine applications.
Example usage
The above HTML will be validated on the client as usual, but using the PHP below will also provide server-side validation without any additional validation logic to be written.
Validation rules present in the above HTML form:
name
input is required to be not empty.email
input is required to be not empty, and must be a valid email address.account
input is not required, but when a value is submitted, it must match the provided regular expression (any number of non-whitespace characters followed by up to 3 numbers).nation
input must be one of the three enumerations present in the<select>
element.
Supported validation mechanisms:
It's possible to add your own validation mechanism by extending the FormValidator
class and overriding the necessary functions.
required
- field can not be left blankpattern
- must match the provided regular expressiontype
- must match the provided inbuilt data typemin
- for numerical inputs, the minimum allowed valuemax
- for numerical inputs, the maximum allowed valueminlength
- the minimum number of characters allowedmaxlength
- the maximum number of characters allowedstep
- the granularity that is required
Supported types:
tel
url
email
date
month
week
time
datetime-local
number
range
Special element behaviour
When using <select>
and <input type="radio" />
elements, their contained options are used as validation enumerations, meaning that values that are not part of the contained options will throw validation errors.