3

A form has the possibilities to disable validation.

<form novalidate/>

Now, I have an HTML5 element not in a form. How to disable validation in that situation?

<noform>
    <input name="email" type="email"/>
</noform>
Niels Steenbeek
  • 4,692
  • 2
  • 41
  • 50

1 Answers1

1

It's not clear exactly what you want to achieve. If the input element is not in a position to be submitted to the server then it will not trigger the validation process, as your comment seems to indicate you've discovered. However, the individual input element can still be in an invalid state irrespective of that process. There are a couple of easy solutions to avoid this:

  • If you don't want the field's validity state to be evaluated as an email, don't use type="email"
  • If you need it to be type email but don't care about it being a valid email (eg. to trigger a particular keyboard mode on a mobile device) then use CSS to hide the indications.

Here's how to hide the normal firefox red glow:

input:-moz-ui-invalid {
    box-shadow: none;
}

And here's a quick example.

robertc
  • 74,533
  • 18
  • 193
  • 177
  • 1
    Excellent answer! One thing: Your solution will still show the validation message. I had to do setCustomValidity(' '); on input. Maybe you can update your example to have the final solution. – Niels Steenbeek Nov 13 '12 at 08:06