Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I am using a Client Validation module for my webforms.

I am seeing a "Please enter an email address" pop up bubble next to the email text field when an incorrect email is entered. I am not quite sure where this is coming from...? Can anyone shed some light?

I would prefer this functionality:

Submitting the form with an empty email field displays a different error message to when an invalid email is entered eg. http://validation7.ubu001.attiks.com/node/1?utm_medium=atix&utm_source=cv7b

share|improve this question

2 Answers 2

Know this was asked a little while ago, but started investigating and found a "solution". Apparently when Webform has a form component with type "Email" it sets the input type to "email". On browsers IE8+ and modern browsers (Chrome, FF) there is an automatic, browser-side verification on these fields. It's nothing to do with the script. It seems to be an html5 "feature", see http://stackoverflow.com/questions/9399528/disable-form-validation-in-browser.

Two options:

  1. Don't use the "Email" type in Webforms. This kind of breaks the ability to use form values as "To" or "From" emails in the Webform Emails feature, so it's not great.

  2. Add the novalidate rule to the <form> generated by Webform. I do so via a custom hook:

    function mymodule_form_alter(&$form,&$form_state,$form_id) {
    
      if(strstr($form_id,'webform') !== FALSE) {  
        // prevent html5 validation, i.e. on input type="email" fields  
        form['#attributes']['novalidate'] = '1';  
      }
    
    }
    

This is just if you want to remove it. Now you can use Webform clientside validation module to set custom messages. Or you can style like here: http://stackoverflow.com/questions/5713405/how-do-you-style-the-html5-form-validation-messages

share|improve this answer

In our instance we used clumsyfingers's code but with parsing fix:

novalidate cannot be "1". It has to be either:

  • no value
  • empty value
  • value = attribute name

like so:

function mymodule_form_alter(&$form,&$form_state,$form_id) {

  if(strstr($form_id,'webform') !== FALSE) {  
    // prevent html5 validation, i.e. on input type="email" fields  
    form['#attributes']['novalidate'] = 'novalidate';  
  }

}

CSE HTML validator was returning this message:

The "novalidate" attribute for the "form" element has an invalid value "1". This is a boolean (true or false) attribute. The presence of a boolean attribute represents true and absense of the attribute represents false. Setting a value is not necessary, but if a value is set, then it must be an empty string or be a case-insensitive match for the attribute's name. NOTE: Never use the values "true" and "false".

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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