Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Use multiple form validations? 
 
arkles
Jr. Member
 
Total Posts:  8
Joined:  2009-01-08
 

I was wondering if anyone knew anything about the form validation?

In the modern theme, the same .validation-failed CSS is used in both the newsletter entry box as well as forms that crop up at checkout, for example. I would like the newsletter entry box to have a different CSS validation-failed style to any forms on the page. Is this possible? I’ve tried to find where the CSS is called from, but can’t find it anywhere.

Any help would be greatly appreciated!

 
Magento Community Magento Community
Magento Community
Magento Community
 
arkles
Jr. Member
 
Total Posts:  8
Joined:  2009-01-08
 

In case anyone stumbles across this in the future, I thought I’d post my fix.

To clarify, this is to change the style from the newsletter subscribtion box ‘validation-failed’ state (by default, it changes the background to red and places a 1px border), WITHOUT changing this same effect when validation fails on an input box elsewhere in the page (for example, wrong values at checkout or sign-in).

I couldn’t find a way to set up two different instances of this, and the defaut .validation-failed CSS rule always overwrote any other div-contained styles I wrote. Instead I used the !important rule in CSS to overwrite the default.

E.g, in the modern theme:

.validation-failed { clear:bothborder:1px solid #eb340a !important; background:#faebe7 !important; }
gives the red boxed effect if a user doesn’t type a correct email address.

By adding the following CSS style (lower down in the CSS file):

.footer .validation-failed { border:0 none !importantbackground:none !important}
we can remove both the border and background color from this validation whilst keeping the red style affecting all other forms outside of the footer.

I know this is probably common knowledge to most, but it took me a good couple of hours to crack, so thought I’d leave the solution for anyone else with this problem.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top