$Moneda = model('XXXX')->XXXX($datos);
$this->validacion->setRules([
'amount' => [
'label' => 'cantidad',
'rules' => 'required|decimal|greater_than_equal_to['.$Moneda['min_withdraw'].']|less_than_equal_to['.$Moneda['max_withdraw'].']',
'errors' => [
'required' => 'Ingrese la cantidad.',
'greater_than_equal_to' => 'El campo de cantidad debe contener un número mayor o igual a 1000.',
'less_than_equal_to'=> 'El campo de cantidad debe contener un número menor o igual a 10000.',
],
],
]);
if ($this->validacion->withRequest($this->request)->run()) {
}else {
$error = $this->validacion->getErrors();
echo json_encode($error);
$this->response->setStatusCode(424);
}
AJAX
$("#retiro").submit(function (e) {
var id = $(this).data('id');
$.ajax({
type: "POST",
url: "/XXXX/XXXX/"+id,
data: "data",
dataType: "dataType",
success: function (response) {
},
statusCode:{
424: function(xhr){
var json = JSON.parse(xhr.responseText);
if (json.required.length !=0) {
alertify.set('notifier','position', 'top-right');
alertify.error(json.required);
}
}
}
});
e.preventDefault();
});
RESULTADO:
Estado
424
Failed Dependency
VersiónHTTP/1.1
Transferido675 B (tamaño 33 B)
Política de referenciastrict-origin-when-cross-origin
amount :"Ingrese la cantidad."
If I enter data in the INPUT I get the same information