0

I've installed both the Clientside Validation module, and Webform Validation, but there is no option to validate for "valid email" in the "Form Validation" tab of the webforms edit panel. Clientside Validation claims to validate for email - what's going on?

How should I go about adding email validation?

  • There should be an "email" webform component. It does not validate? – Mołot Aug 29 '13 at 7:13
1

Currently it seems there is no such functionality, as it still sits in issue queue as a feature request. You can either:

  • I checked my webform, it validate by itself, no need extra functionality (for example if i type wrong email like "dfgdfh"). can you please look in to this – Bala Aug 29 '13 at 7:35
  • @Bala maybe someone just forgot to update feature request's status, then? – Mołot Aug 29 '13 at 7:37
1

try with this code inside your form alter:

// Add a callback function to your email field.
$form['mail']['#ajax'] = array(
  'callback' => 'email_validation',
  'wrapper' => 'email_validation_message',
);

// Field-wrapper to display result message
$form['email_presence_message'] = array(
  '#type' => 'markup',
  '#prefix' => '<div id="email_presence_message">',
  '#suffix' => '</div>',
  '#weight' => -1,
);

The ajax callback:

/**
 * Ajax callback.
 */
function email_validation($form, $form_state) {

  if (!valid_email_address($form_state['values']['email'])) {
    form_set_error('email', t('That e-mail address is not valid.'));
    $form['email_presence_message']['#markup'] = t('email not valid');
    return $form['account']['email_presence_message'];

  }

}

0

I have been experinced the same problem since, the first version of my website was a real issues and bad design... i found this, hopefully helps you... https://drupal.org/project/clientside_validation

  • just select, Regular expresion Case- insensitive on form validation tab and add this regex. ^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$ worked perfectly for me, because I had data and the email field was created as text not as E-mail.. – Mario Cantor May 28 '14 at 21:07
0

You can use valid_email_address() function to validate your email.

function MyModule_form_validate($form, &$form_state) {
    if (!valid_email_address($form_state['values']['email'])) {
        form_set_error('email', t('That e-mail address is not valid.'));
    }
}
0

Use the Webform Validation module and use Regular expression, case-insensitive.

Eg:

  1. For name validation: \b[A-Z]{3,30}\b
  2. For mobile number: \b[0-9]{10,15}\b

Now you can use any regular expression to validate your web form.

0

Get Email Verification module. Though it is still in development for durpal 7.0 it works fine.

-1

Webform Validation with this module you can set validation rules for each fields see the below image.

This module adds an extra tab to each webform node, allowing you to specify validation rules for your webform components. You can create one or more of the predefined validation rules, and select which webform component(s) should be validated against those.

enter image description here

  • but OPs question is really "What's the proper validator for E-mail?" – Mołot Aug 29 '13 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.