I'm working with a styled form, combining a number of jQuery plugins to help style form elements such as <select>
and <input type="checkbox" />
. These plugins hide the original form input and replace them with a styleable set of alternative HTML elements (<div>
, <a>
, <ul>
, etc.). The only issue is they don't seem to handle the [required]
attribute and apply the browsers' (Firefox, Chrome) box-shadow effects if the user attempts to submit the form without filling the required fields. Is there a simple way I can get those [required]
attributes to translate onto the replacement elements? I would just extend the plugins and have them copy the [required]
attribute to the replacement element, but I doubt that <div>
tags support [required]
. I've looked around on the Internets, but haven't found much in the way of helpful guides. Is there a workaround I'm missing? I just can't think of how to do it.
I suppose I could use full-fledged client-side validation, but I'm trying to keep the jQuery/JavaScript intervention to a minimum. If there isn't a good way to do this, I'll just go use a form validation plugin or something. For now, just for the sake of style consistency, I've disabled all the box-shadow effects with some CSS:
input:invalid, input:required,
textarea:invalid, textarea:required,
select:invalid, select:required {
-webkit-box-shadow: none;
-moz-box-shadow: none;
-box-shadow: none;
}
...
` follows the `input` element and you're trying to style `p.someElementClass`. – 0b10011 Jun 26 '12 at 18:01