Reputation: 94
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.
Upvotes: 1
Views: 2722
Reputation: 2617
Make sure this line:
$('#remarks').parsley( 'addConstraint', { minlength: 5 });
is called before you check isValid()
.
Upvotes: 1