[ class tree: HTML_QuickForm2 ] [ index: HTML_QuickForm2 ] [ all elements ]

Class: HTML_QuickForm2_Rule_Email

Source Location: /HTML_QuickForm2-2.1.0/HTML/QuickForm2/Rule/Email.php

Class Overview


Validates email address



  • Release: 2.1.0


Inherited Variables

Inherited Methods

Class: HTML_QuickForm2_Rule

Class constructor
Adds a rule to the chain with an "and" operator
Returns the rule's configuration data
Returns the client-side representation of the Rule
Returns the client-side validation callback
Returns IDs of form fields that should trigger "live" Javascript validation
Returns the error message output by the rule
Returns IDs of form fields that should trigger "live" Javascript validation
Merges local configuration with that provided for registerRule()
Adds a rule to the chain with an "or" operator
Sets configuration data for the rule
Sets the error message output by the rule
Sets the element that will be validated by this rule
Sets the error message on the owner element
Performs validation
Validates the owner element

Class Details

[line 61]
Validates email address

Email address format as defined in RFCs 822, 2822 and 5322 is quite complex and has many uncommon features. This rule was designed with registration forms in mind, where a user usually enters her email address in order to receive a newsletter or a confirmation. So it currently supports a most common subset of email address format, disallowing

  • domain literals like root@[] or root@[IPv6:::]
  • quoted strings in local part "John Doe"
Support for these may be added in the future, until then you may consider using PHP filter_var() function with FILTER_VALIDATE_EMAIL. Note also that the characters "-", "_", "+", "!", "#", "$", "%", "&", "'", "*", "/", "=", "?", "^", "`", "{", "|", "}", "~" are valid in the local part of email address according to RFC, though most of these are highly improbable in any reallife address. We may add a means of limiting this list in the future, for now you may use the 'notregex' rule to disallow some of these if needed.

As recommended in the RFC, the local part must not be longer than 64 characters and the domain part 255. This means that the address can be up to 320 characters long. The number of subdomains is arbitrary limited to 10. You can use the maxlength rule in conjunction if you need to enforce shorter addresses. A length of 100 for the whole address is usually far enough.

[ Top ]

Method Detail

getJavascriptCallback   [line 103]

string getJavascriptCallback( )

Returns the client-side validation callback
  • Access: protected

Overrides HTML_QuickForm2_Rule::getJavascriptCallback() (Returns the client-side validation callback)
[ Top ]

validateOwner   [line 68]

bool validateOwner( )

Validates the owner element
  • Return: whether element's value is in a commonly used email address format
  • Access: protected

Overrides HTML_QuickForm2_Rule::validateOwner() (Validates the owner element)
[ Top ]

Documentation generated on Wed, 10 Apr 2019 08:56:09 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.