Actions

Difference between revisions of "Server-side form validation"

From Joomla! Documentation

m (Validation rules: wikitable standard class, coloring too close to incomplete template)
(Setting inuse, filling todo fields, adding file location info.)
Line 1: Line 1:
{{incomplete}}{{Review}}
+
{{incomplete}}{{Review}}{{inuse}}
 
After submitting a form, you should validate your data. In Joomla this can be done via the JForm validate method (normally called in the controller via the model JModelForm).
 
After submitting a form, you should validate your data. In Joomla this can be done via the JForm validate method (normally called in the controller via the model JModelForm).
  
Line 16: Line 16:
 
|
 
|
 
'''boolean'''
 
'''boolean'''
| Todo
+
| Accepts only the values '0', '1', 'true' or 'false' (case-insensitive).
| Todo (e.g. {{JVer|1.5}} and newer)
+
| {{JVer|11.1}} and newer
 
|-
 
|-
 
|
 
|
Line 68: Line 68:
 
|-
 
|-
 
|}
 
|}
 +
 +
You can find the specific implementation of these rules in \libraries\joomla\form\form.php - validation begins in the function validate(), moves to validateField(), which then calls the respective validation functions of \libraries\joomla\form\rules\*.php
  
 
==Server- or Client-side validation?==
 
==Server- or Client-side validation?==

Revision as of 22:55, 17 August 2013

Quill icon.png
Content is Incomplete

This article or section is incomplete, which means it may be lacking information. You are welcome to assist in its completion by editing it as well. If this article or section has not been edited in several days, please consider helping complete the content.
This article was last edited by DewiMorgan (talk| contribs) 13 months ago. (Purge)

Copyedit.png
This Article Needs Your Help

This article is tagged because it NEEDS REVIEW. You can help the Joomla! Documentation Wiki by contributing to it.
More pages that need help similar to this one are here. NOTE-If you feel the need is satistified, please remove this notice.

Quill icon.png
Page Actively Being Edited!

This article is actively undergoing a major edit for a short while.
As a courtesy, please do not edit this page while this message is displayed. The user who added this notice will be listed in the page history. This message is intended to help reduce edit conflicts; please remove it between editing sessions to allow others to edit the page. If this page has not been edited for several hours, please remove this template, or replace it with {{underconstruction}} or {{incomplete}}.

After submitting a form, you should validate your data. In Joomla this can be done via the JForm validate method (normally called in the controller via the model JModelForm).

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.

E.g. field in a joomla form xml

<field name="email" type="text" class="inputbox" description="Fill in your E-mail" label="E-mail" required="true" validate="email" size="30" />

Validation rules

Rule Description Availability

boolean

Accepts only the values '0', '1', 'true' or 'false' (case-insensitive). Joomla 11.1 and newer

color

Todo Todo (e.g. Joomla 1.5 and newer)

email

Todo Todo (e.g. Joomla 1.5 and newer)

equals

Todo Todo (e.g. Joomla 1.5 and newer)

options

Requires the value entered be one of the options in a field of type="list" Joomla 11.1 and newer

rules

Todo Todo (e.g. Joomla 1.5 and newer)

tel

Telephone number (nanpa, ITU-T T-REC-E.164 or ietf rfc4933) Joomla 11.1 and newer

url

Todo Todo (e.g. Joomla 1.5 and newer)

username

Todo Todo (e.g. Joomla 1.5 and newer)

You can find the specific implementation of these rules in \libraries\joomla\form\form.php - validation begins in the function validate(), moves to validateField(), which then calls the respective validation functions of \libraries\joomla\form\rules\*.php

Server- or Client-side validation?

Form validation