Skip to content

Commit cde7af5

Browse files
azambonfballianokiatng
authored
Avoid JS errors if the zipcode field has no label (OpenMage#3197)
Co-authored-by: Fabrizio Balliano <[email protected]> Co-authored-by: Ng Kiat Siong <[email protected]>
1 parent a6c6753 commit cde7af5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

js/varien/form.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -384,13 +384,13 @@ ZipUpdater.prototype = {
384384

385385
_setPostcodeOptional: function(){
386386
this.zipElement = $(this.zipElement);
387-
if (this.zipElement == undefined) {
387+
if (this.zipElement === undefined) {
388388
return false;
389389
}
390390

391391
// find label
392392
var label = $$('label[for="' + this.zipElement.id + '"]')[0];
393-
if (label != undefined) {
393+
if (label !== undefined) {
394394
var wildCard = label.down('em') || label.down('span.required');
395395
if (!wildCard) {
396396
label.insert(' <span class="required">*</span>');
@@ -400,21 +400,21 @@ ZipUpdater.prototype = {
400400

401401
// Make Zip and its label required/optional
402402
if (optionalZipCountries.indexOf(this.country) != -1) {
403-
if (label.hasClassName('required')) {
403+
if (label !== undefined && label.hasClassName('required')) {
404404
label.removeClassName('required');
405405
}
406406
while (this.zipElement.hasClassName('required-entry')) {
407407
this.zipElement.removeClassName('required-entry');
408408
}
409-
if (wildCard != undefined) {
409+
if (wildCard !== undefined) {
410410
wildCard.hide();
411411
}
412412
} else {
413-
if (!label.hasClassName('required')) {
413+
if (label !== undefined && !label.hasClassName('required')) {
414414
label.addClassName('required');
415415
}
416416
this.zipElement.addClassName('required-entry');
417-
if (wildCard != undefined) {
417+
if (wildCard !== undefined) {
418418
wildCard.show();
419419
}
420420
}

0 commit comments

Comments
 (0)