ユーザーがクーポンを入力するクーポンコードフィールドを持つショッピングカートフォームがあり、それが空白かどうかを検証します。同じフォームに、ストライプ ポップアップ クレジット カード支払いボックスをトリガーする別のボタンもあります。クレジット カードの支払いを完了すると、クーポン コードのテキスト ボックスで「必須フィールド」エラーが表示されますが、これは発生すべきではありません。
<form action="/cart/" method="post" id="promotion-form" name="submit_promotion">
<textarea placeholder="Enter promotional code" class="promotional-box" name="code" id="code"></textarea>
<input type="hidden" value="1" name="plan_id" id="plan_id">
<button class="btn-apply pull-right" name="promotion-submit" type="submit">Apply</button>
</form>
JQuery
$('#promotion-form').validate(
{
rules: {
code: {
minlength: 5,
required: true
}
},
highlight: function(element) {
$(element).closest('.control-group').removeClass('success').addClass('error');
},
success: function(element) {
}
});