jQuery validation plugin error: TypeError: validator is undefined

后端 未结 13 2380
无人及你
无人及你 2020-12-09 03:10

Here is html code for the form:

13条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-09 03:29

    Same happened here. For me it was a typo in my code:

    $(document).ready(function(){
        //START of validate
    $('#reply').validate({
        rules:{
            message:{
                required: true,
                },  
            },
        submitHandler: function(form) {
            var data = $("#reply").serialize();
            $.ajax({
                type:"POST",
                url:"ajax/scripts/msg_crt.php",
                data:data,
                success:function(data){
                    alert("Loaded");
                    }
                });
            }
        });
        //END of validate
      });
    
    $(document).on('click','#send', function(){
        if($('#replay').valid()){// <--- Here is my selector typo
            $("#replay").submit(); // <--- Here is my selector typo
            }
            return false;
        });
    

提交回复
热议问题