开发者

JavaScript form validation maxVALUE

开发者 https://www.devze.com 2023-03-21 06:44 出处:网络
Where minvalue is now I would actually like to have a maxvalue of 12. What is the code for max value instead of min value? Thanks!

Where minvalue is now I would actually like to have a maxvalue of 12. What is the code for max value instead of min value? Thanks!

This uses jQuery and jquery.validate:

$(document).ready(function() {
    $('#form').validate({
        rules: {
            username: {required:true, minlength:12},
            items: {required:true, r开发者_JAVA技巧ange:[1,100]},
        }

EDIT: I realize I actually need max value, not max length, So what is the jQuery for max value?


To make an element require a given maximum, use max:

$("#myform").validate({
  rules: {
    field: {
      required: true,
      max: 23
    }
  }
});
0

精彩评论

暂无评论...
验证码 换一张
取 消