Adrian
Adrian

Reputation: 2012

Validation plugin not working with one field

I have quite a simple form and am trying to have one field required.

But nothing is happening when I submit with a blank field: it still submits.

$(document).ready(function() {
    jQuery("#commentForm").validate({
        rules:{
            message_name:{
                required:true
            }
        },
        messages:{
            message_name:{
                required:"Name Required"
            }
        }
    });
});

<form id="case-study-form" action="<?php get_option("siteurl");?>/case-study-downloads/"  method="post"  >
    <p><label class="modal-label" for="name">Name: <span>*</span></label> <input type="text" name="message_name" id="message_name" class="required" value=""></p>
    <p><input type="submit" value="Submit" ></p>
</form>

Upvotes: 0

Views: 61

Answers (1)

vdwijngaert
vdwijngaert

Reputation: 1555

Your form ID doesn't match with the jQuery selector.

Upvotes: 5

Related Questions