Skip to content

Commit 27a046c

Browse files
committed
validate coupon generate fiend onchange element issue 23778
1 parent 6f2927b commit 27a046c

File tree

2 files changed

+13
-4
lines changed
  • app/code/Magento/SalesRule

2 files changed

+13
-4
lines changed

app/code/Magento/SalesRule/Block/Adminhtml/Promo/Quote/Edit/Tab/Coupons/Form.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ protected function _prepareForm()
7777
'label' => __('Coupon Qty'),
7878
'title' => __('Coupon Qty'),
7979
'required' => true,
80-
'class' => 'validate-digits validate-greater-than-zero'
80+
'class' => 'validate-digits validate-greater-than-zero',
81+
'onchange' => 'window.validateCouponGenerate(this)'
8182
]
8283
);
8384

@@ -91,7 +92,8 @@ protected function _prepareForm()
9192
'required' => true,
9293
'note' => __('Excluding prefix, suffix and separators.'),
9394
'value' => $couponHelper->getDefaultLength(),
94-
'class' => 'validate-digits validate-greater-than-zero'
95+
'class' => 'validate-digits validate-greater-than-zero',
96+
'onchange' => 'window.validateCouponGenerate(this)'
9597
]
9698
);
9799

@@ -103,7 +105,8 @@ protected function _prepareForm()
103105
'name' => 'format',
104106
'options' => $couponHelper->getFormatsList(),
105107
'required' => true,
106-
'value' => $couponHelper->getDefaultFormat()
108+
'value' => $couponHelper->getDefaultFormat(),
109+
'onchange' => 'window.validateCouponGenerate(this)'
107110
]
108111
);
109112

@@ -138,7 +141,8 @@ protected function _prepareForm()
138141
'title' => __('Dash Every X Characters'),
139142
'note' => __('If empty no separation.'),
140143
'value' => $couponHelper->getDefaultDashInterval(),
141-
'class' => 'validate-digits'
144+
'class' => 'validate-digits',
145+
'onchange' => 'window.validateCouponGenerate(this)'
142146
]
143147
);
144148

app/code/Magento/SalesRule/view/adminhtml/templates/promo/salesrulejs.phtml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ function generateCouponCodes(idPrefix, generateUrl, grid) {
8686
});
8787
}
8888

89+
function validateCouponGenerate(elm) {
90+
jQuery.validator.validateSingleElement(elm);
91+
}
92+
93+
window.validateCouponGenerate = validateCouponGenerate;
8994
window.generateCouponCodes = generateCouponCodes;
9095
window.refreshCouponCodesGrid = refreshCouponCodesGrid;
9196
});

0 commit comments

Comments
 (0)