【问题标题】:jquery validation in textfield文本字段中的 jquery 验证
【发布时间】:2018-11-28 03:32:16
【问题描述】:

当我在谷歌冲浪时,我得到了插件(jquery 表单验证器),我想做表单验证,插件在表单验证中使用,它的工作完美但在控制台显示错误,

jquery.form-validator.min.js:9 Uncaught TypeError: Cannot read property 'length' of undefined
在 HTMLDocument.f (jquery.form-validator.min.js:9)
在 HTMLDocument.dispatch (jquery.js:3)
在 HTMLDocument.r.handle (jquery.js:3)
在 Object.trigger (jquery.js:3)
在 m.fn.init.triggerHandler (jquery.js:3)
在 Function.ready (jquery.js:2)
在 HTMLDocument.J (jquery.js:2)

$.validate({
  form: '#form',
  modules: 'location, date, security, file',
});

// Restrict presentation length
$('#presentation').restrictLength($('#pres-max-length'));
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-form-validator/2.3.26/jquery.form-validator.min.js"></script>

<div class="form-group col-lg-5">
  {!! Form::label('quantities', 'Traded Quantity:') !!} {!! Form::text('quantities', null, ['class'=>'form-control', 'data-validation'=>'length number', 'data-validation-length'=>'3-12', 'data-validation-error-msg'=>'User name has to be an alphanumeric
  value (3-12 chars)'])!!}
</div>

【问题讨论】:

  • HTML 中有#pres-max-length 字段吗?
  • 不使用#pres-max-length,它使用data-validation-length -@RoryMcCrossan
  • $('#presentation').restrictLength($('#pres-max-length'));此行发表评论,工作正常 -@RoryMcCrossan
  • 正是我的观点:)

标签: jquery laravel laravel-5 laravel-4 jquery-plugins


【解决方案1】:

您可以通过以下方式对其进行验证:

    $('#form').validate({
       rules: {
        quantities: {
            required: true,
            rangelength: [3, 12],
        },
        other_input_name: "required",
     },
  });

【讨论】:

    猜你喜欢
    • 2011-11-09
    • 1970-01-01
    • 2018-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-27
    • 2019-04-24
    • 2012-06-24
    相关资源
    最近更新 更多