Firefox 4 Required input form RED border/outline
Asked Answered
E

5

61

I have recently developed an HTML5 jQuery plugin and I'm having trouble removing the red border on required fields in FF4 beta.

I noticed that FF applies this border/outline in required fields and removes it when value is set. The problem is that I am using the value attribute to emulate the placeholder attr in older browsers. Therefore I need all inputs with this feature to not show the red line.

You can see the problem in the demo page of the plugin here

Erelong answered 28/9, 2010 at 1:51 Comment(0)
K
111

There's some new pseudo selectors for some of the new HTML5 form features available to you in CSS. You're probably looking for :invalid. The following are all from the MDC Firefox 4 docs:

  • The :invalid CSS pseudo-class is applied automatically to elements whose contents fail to validate according to the input's type setting

  • The :-moz-submit-invalid pseudo-class is applied to the submit button on form fields when one or more form fields doesn't validate.

  • The :required pseudo-class is now automatically applied to fields that specify the required attribute; the :optional pseudo-class is applied to all other fields.

  • The :-moz-placeholder pseudo-class has been added, to let you style placeholder text in form fields.

  • The :-moz-focusring pseudo-selector lets you specify the appearance of an element when Gecko believes the element should have a focus indication rendered.

Kisor answered 28/9, 2010 at 2:4 Comment(3)
i set up the -moz-mox-shadow property to 'none'.Erelong
You should really check his answer as "the answer", and give him an up arrow, that's how this site works. Doing that would be a big thanks :DCamlet
There's also the :-moz-ui-invalid pseudo-class, which applies in a subset of cases for :invalid. Gecko uses it and applies a red glow using the box-shadow propertyArrowwood
T
83

To be more specific you need to apply that style to the input control.

input:invalid {
    box-shadow: none;
}
Trimming answered 20/5, 2011 at 13:52 Comment(2)
Scratch that. Simply box-shadow:none worked for me now. Sorry for the incompetence.Unregenerate
Add textarea also. input:invalid, textarea:invalid { box-shadow: none; }Orlandoorlanta
V
49

use this code as Quick and simple solution

:invalid {
  box-shadow: none;
}

:-moz-submit-invalid {
  box-shadow: none;
}

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

Reference:- https://developer.mozilla.org/en-US/docs/Web/CSS/:invalid

Virus answered 7/4, 2014 at 23:56 Comment(3)
This worked perfectly for me to remove (never show) the red border around input fields when invalid in Firefox. Thanks!Nigrify
The third element is what removed the red box for me.Rickeyricki
@Andrew Swift use all of them for compatibilityVirus
S
0

Please try this,

$("form").attr("novalidate",true);

for your form in your global .js file or in header section.

Spirelet answered 29/5, 2015 at 8:56 Comment(0)
H
0

Wrap your required input into a form with novalidate attribute

<form novalidate>
    <input required>
</form>
Homerus answered 25/10, 2017 at 11:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.