Bootstrap not validating with ajax

My form sends over even though the field is empty. Can someone please help me check what’s wrong?

$(document).ready(function () {
                //validation rules
                $("#insertInquiry").validate({
                    rules: {
                        "comment": {
                            required: true,
                        } 
                       
                    },
                    //perform an AJAX post to ajax.php
                    submitHandler: function() {
                        type: "POST",
				url: "http://ospar.hostzi.com/pages/patientMessage",
				data: $("#insertInquiry").serialize(),
				success: function(msg){
					if(msg=="1")
					{
						$(".sentMsg").text('Message Sent');
						
					}
					else
					{
						$(".sentMsg").text('Message Not Sent');
						
					}
                    }
                });
            });

my view:

<form id="insertInquiry" role="form" action="http://ospar.hostzi.com/pages/patientMessage" method="POST" data-toggle="validator">		
							<div class="form-group">
								<label for="Username">Questions? Send us a message...</label>
							</div>
							<div class="form-group">
								<label for="comment">Inquiry:</label>
								<textarea class="form-control" rows="5" id="comment" name="patientinquiry" required></textarea>
							</div>
							<button type="submit" class="btn btn-default" value="Submit">Submit</button><p class="sentMsg"></p>
						</form>

Or is there any way to validate a form before sending the request in ajax?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.