简体   繁体   English

jQuery欧芹验证不起作用

[英]Jquery parsley validate not working

if($("#dataform").parsley().isValid()){
    $.ajax({
        url  : '<?php echo base_url();?>index.php/company/final_review?id=<?php echo $this->input->get('id'); ?>',
        type : 'POST',
        data : $("#dataform").serialize(),
        dataType:"json",
        beforeSend: function(){
            $('#remarks').parsley( 'addConstraint', { minlength: 5 });
        },
        success : function(data){
            console.log(data);
        }     
    });
}

This is my ajax part. 这是我的ajax部分。 The plugin is not validating the field it's submitting the form. 插件未验证其提交表单的字段。 The form validation is working fine. 表单验证工作正常。 But i want to validate the remark field with min length . 但是我想用最小长度来验证备注字段。 That is not working. 那是行不通的。

Make sure this line: 确保这一行:

$('#remarks').parsley( 'addConstraint', { minlength: 5 });

is called before you check isValid() . 在检查isValid()之前被调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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