Jquery parsley validate not working

2.6k views Asked by At
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. 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.

1

There are 1 answers

0
theduck On BEST ANSWER

Make sure this line:

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

is called before you check isValid().