0

私は次のコードを持っています:

<form id="reg_form_pay" class="fancy_form" action="" method="POST">
  <div class="wrap_input" style="margin-bottom: 10px;">
    <p class="inp_label">Firstname:</p>
    <i> </i>
    <input id="pay_firstname" type="text" value="" name="FirstName" style="width: 157px;">
  </div>
  <div class="wrap_input" style="margin-bottom: 10px;">
    <p class="inp_label">Surname:</p>
    <i> </i>
    <input id="pay_lastname" type="text" value="" name="Surname" style="width: 157px;">
  </div>
  <div class="wrap_input" style="margin-bottom: 10px; margin-top: 34px;">
    <p class="inp_label">E-mail:</p>
    <i> </i>
    <input id="pay_email" type="text" value="" name="Email" style="width: 157px;">
  </div>
  <div class="wrap_input" style="margin-top: 34px;">
    <p class="inp_label">Phone:</p>
    <i> </i>
    <input id="pay_phone" type="text" value="" name="PhoneNumber" style="width: 157px;">
  </div>
</form>

そして検証:

$("#reg_form_pay").validate({
            rules: {
                Email: { required: true, email: true, checkEmail: true },
                PhoneNumber: { required: true, checkPhoneNumber: true },
                FirstName: { required: true },
                Surname: { required: true }
            }, 
        });

デフォルトではlabel、検証がfalseの場合にバリデーターが書き込みます。エラーの説明を含む要素を追加したくありません。errorclassを使用して親divにクラスを追加したいwrap_input。これを行うためにバリデーターにどのように言うことができますか?
ありがとう。

4

1 に答える 1

1

に送信されるオプションにこれを追加すると、validate機能します。

showErrors: function(errorMap, errorList) {
    $.each(errorList,function(i,e){
        $(e.element).parents('.wrap_input').addClass('error');
    });                   
}

実例: http: //jsfiddle.net/nqp8J/

于 2012-08-22T09:11:21.337 に答える