2017-12-15 4 views
0

私は自分の「連絡先」フォームを検証していますが、エラーメッセージを表示する方法を理解できません。私はドキュメントを読むことを試みたが、私はちょうどerrorPlacement機能を使用する方法を理解していない。誰かが私に持っているコードでそれを行う方法の例を私に見せてもらえますか?jQuery Validatorでエラーメッセージを追加するには

<fieldset> 
    <input placeholder="Ditt navn" name="contact_name" id="contact_name" class="contact_input" type="text" tabindex="1" required autofocus> 
</fieldset> 
<fieldset> 
    <input placeholder="Din email adresse" name="contact_mail" id="contact_mail" class="contact_input" type="email" tabindex="2" required> 
</fieldset> 
<fieldset> 
    <input placeholder="Firma navn (valgfri)" name="contact_firmname" id="contact_firmname" class="contact_input" type="text" tabindex="3"> 
</fieldset> 


$(document).ready(function(){ 
    $('body').on('keyup','#contact_me',function(){ 
     $('#contact_me').validate({ 
     rules: { 
      contact_name: { 
      required: true, 
      remote: location.protocol + '//' + location.host+'/ajax_contact.php' 
      }, 
      contact_mail: { 
      required: true, 
      remote: location.protocol + '//' + location.host+'/ajax_contact.php' 
      }, 
      contact_firmname: { 
      }, 
     }, 
     errorPlacement: function(){ 
      return false; 
     }, 
     submitHandler: function (form) { 
      return false; 
     } 
    }); 
    }); 
}); 

答えて

関連する問題