City and state validation problem after Magento upgrade

On many of our Magento webshops we encountered the following problems after upgrading:

  • The city field (looked as if) it was no longer required;
  • The state field (looked as if) it was suddenly required.

After doing some research the situation is actually that the city field is still required, the asterisk is however missing

-and- the state/province field is actually NOT required, but it shows the * sign.

So summarizing: the asterisk sign got misplaced after the upgrade. On the forum’s several solutions have been posted. This one looks the best to us (eventough it is a core file modification):

Open: /js/varien/form.js, around line 246:

REPLACE:

setMarkDisplay: function(elem, display){
elem = $(elem);
var labelElement = elem.up(1).down('label > span.required') ||
elem.up(2).down('label > span.required') ||
elem.up(1).down('label.required > em') ||
elem.up(2).down('label.required > em');
if(labelElement) {
display ? labelElement.show() : labelElement.hide();
}
}

WITH

setMarkDisplay: function(elem, display){
elem = $(elem);
var labelElement = elem.up('div.input-box').down('label > span.required') ||
elem.up('div.input-box').down('label.required > em');
if(labelElement) {
display ? labelElement.show() : labelElement.hide();
}
}

That should solve it! Contact us if you have any questions: info@younify.nl

If you need any help on this post, or are looking for an experienced Magento partner, feel free to contact us!

~ by emilekoolstra on August 17, 2009.

5 Responses to “City and state validation problem after Magento upgrade”

  1. Excellent! That’s solved this annoying problem. Many thanks.

  2. Thank you very much!!! problem solved.

  3. Thanks for this – hopefully this gets fixed in core soon :)

  4. Thank you, this is a very usefull post

  5. Thanks, sorted my issue out on Magento ver. 1.3.2.4.

Leave a Reply