简体   繁体   中英

jQuery validation not validating onkeyup

Can someone help me understand why onkeyup validation is not working? I have been staring at it too long! Thanks.

JSFiddle here.

Code:

$(document).ready(function () {

    jQuery('#DSH0000000146FF').validate({
        rules: {
            dish_name: {
                required: true
            },
            dish_description: {
                required: true
            }
        },
        messages: {
            dish_name: {
                required: "Please enter a name, no longer than 80 characters."
            },
            dish_description: {
                required: "Please enter a description, no longer than 240 characters."
            }
        },
        submitHandler: function (form) {
        if(jQuery('#DSH0000000146FF').validate()){
                 alert("SUBMITTED!");
         }
         else{
           }
        }
    });

});

Add submit button to form

<textarea id="DSH0000000146d" name="dish_description" 
      class="textarea-comment dish_description" maxlength="240">More testing
</textarea><br/>
<input type="submit"></input> <!-- Add this line -->

jsfiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM