Download the PHP package muhammadsiyab/form_validation without Composer
On this page you can find all versions of the php package muhammadsiyab/form_validation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download muhammadsiyab/form_validation
More information about muhammadsiyab/form_validation
Files in muhammadsiyab/form_validation
Package form_validation
Short Description PHP Form Validation Library
License MIT
Informations about the package form_validation
PHP Form Validation Library
Performs Server-Side validation of HTML Forms
Downloading and implementation
-
run command
- Include Form_Validation library
Validating form
Available methods
1. validate
Validates the form using specified rules
Parameters:
array$config Array that contains validation configurationExample
array('field_name', 'field_label', 'validation_rules_separated_with_pipe', array_containing_custom_messages)
2. exists
Checks whether a value already exists in database
Parameters:
-
string$field Data related with field e.g name & labelExample
'field_name|field_label' -
string$db Database connection details e.g host, user, password & database nameExample
'localhost|user|password|db_name' -
string$table Data related with table e.g table name & column nameExample
'table_name|column_name' string$error (Optional) Custom error to show
3. set_error_markup
Sets custom markup for validation errors
-
string$opening_markup String containing opening markupExample
'<span style="color: red">' string$closing_markup String containing closing markupExample
'</span>'
4. show_validation_errors
@return type Array (Use for loop to iterate through errors)
Shows validation errors
5. is_form_ok
Checks whether validation is done with errors or not
Available validation rules
| Rule | Description | Syntax |
|---|---|---|
| required | Checks if a field is empty | required |
| numeric | Checks if a field is not a number | numeric |
| Checks if email is invalid | email |
|
| url | Checks if url is invalid | url |
| ip | Checks if IP address is invalid | ip |
| min_length | Sets the minimum length of field | <6 |
| max_length | Sets the maximum length of field | >10 |
| regex | Performs regular expression for the field | matches/^[a-zA-Z0-9]/ |