forked from stripe-archive/jquery.payment
-
Notifications
You must be signed in to change notification settings - Fork 105
Email Address
Omar Shammas edited this page Sep 13, 2013
·
1 revision
You cannot format an email address field because there is no structure.
Before everybody goes on a rant, I agree that the only way to validate an email address is to send it an email. However, some client side validation does not hurt especially since 99% of email addresses won't have multiple @
symbols and be top level domains.
If you want to contribute another email validator by all means do so. It would be helpful to have multiple email validators with varying degrees of coverage.
Validates the email address:
- Validates the email address using the algorithm specified by the data attribute
formance_algorithm
. By default thesimple
algorithm is used. - For now there are only 2 algorithms
simple
andcomplex
. - Simple is very lenient and as a result there can be false positives (an email is labelled a valid when it is invalid).
- Complex as the name suggests, is less forgiving and works for 99% cases, but it results in more false negatives (an email address is labelled as invalid when it is valid).
$("<input value='john@example.com' />").formance('validate_email'); // true
$("<input value='john@example.com' data-formance_algorithm='simple' />").formance('validate_email'); // true
$("<input value='john@example.com' data-formance_algorithm='complex' />").formance('validate_email'); // true
$("<input value='postbox@com' data-formance_algorithm='simple' />").formance('validate_email'); // true
$("<input value='postbox@com' data-formance_algorithm='complex' />").formance('validate_email'); // false