Validator
Client-side form validation with inline error messages, blur/input triggers, and built-in rules. Prevents layout shifts by using Manhattan styling instead of native HTML5 validation.
Registration Form Example
Fill out the form and submit to see validation...
PHP PHP Methods (Fluent)
| Method / Property | Parameters | Description |
|---|---|---|
$m->validator($formId) | string | Create a validator targeting the form with the given ID. |
->field($name, $message, $rules) | string, string, array | Add a field to validate. Flag rules are plain strings ('required', 'email'); value rules are single-key arrays (['minLength' => 8], ['pattern' => '^\.+$']). |
->onSubmit($callback) | string | JS code to execute when the form passes all validation. |
->validateOnBlur($enabled) | bool | Validate fields when they lose focus (default: true). |
->validateOnInput($enabled) | bool | Validate fields in real-time on each keystroke (default: false). |
JS JS Validation Rules
| Method / Property | Parameters | Description |
|---|---|---|
required | | Field must have a non-empty value. |
email | | Value must be a valid email address. |
minLength | int | Minimum string length. |
maxLength | int | Maximum string length. |
min | number | Minimum numeric value. |
max | number | Maximum numeric value. |
integer | | Value must be a whole number. |
positive | | Value must be a positive number. |
pattern | string (regex) | Value must match the given regex pattern. |
custom | function(value, input) | Custom validation function returning true/false. |