perhaps this is the most silly question but I really don't know how to solve this problem.
I'm using parsley.js and I did a password field validation using parsley's data-remote:
View snippet:
<form data-parsley-validate novalidate class="form-horizontal group-border-dashed" id= "form-val" role="form" action="{site_url()}admin/checkPass" method="post" enctype="multipart/form-data">
<div class="form-group">
<div class="col-sm-4">
<label>Contraseña Actual</label>
</div>
<div class="col-sm-7">
<input id="actualPass" type="password" name="actualPass" data-parsley-remote="{site_url()}admin/checkPass" data-parsley-remote-options="POST" data-remote-datatype="jsonp" class="form-control" required>
</div>
</div>
On my admin.php:
public function checkPass(){
if (isset($_POST['actualPass'])) {
$passMd5 = md5($_POST['actualPass']);
$pass = ($this->data['actualUserBack']->user_password);
if ($passMd5 == $pass) {
echo json_encode(true);
}else{
echo json_encode(false);
}
}
}
I have other fields (new password and retype new password) that works super with this parsley's validation. When you input wrong passwords then a message in red appears.
What I want to have is the same red box with a custom message in the first validation I've made. From admin.php/checkPass I'm only returning true and false in a blank page.
How do I do to use parsley validation format in that case?
Here I attach images:
What shows first checkPass function: image 1
How I want it to look: image 2
How do I send the data? what do I have to modify or add? thanks!