Is that possible?
I already wrote a simple validator that is triggered when the form is submitted. Can I use the same validator, but it must be triggered right after the input field has been left.
is it possible? pablo
Is that possible?
I already wrote a simple validator that is triggered when the form is submitted. Can I use the same validator, but it must be triggered right after the input field has been left.
is it possible? pablo
It would be possible, here is one way to go about it.
onblur
event to the form element Zend_Form::isValidPartial
to check the populated elementHope that helps.
This is part of working example:
Backend:
class UserController extends Zend_Controller_Action
{
/* ... */
public function validateAction()
{
if ($this->_request->isXmlHttpRequest()) {
$values = $this->_request->getParam('values');
$form = new Form_User();
$isValid = true;
if (!$form->isValidPartial($values)) {
$isValid = $form->getMessages();
}
$this->_helper->json(array('errors' => $isValid));
}
}
/* ... */
}
Frontend, (just ajax call part) should be attached on event:
$.ajax({
type: "POST",
url: "/user/validate/",
data: {
'values': $('#my-form-id').serialize()
},
dataType: "json",
beforeSend:function(){
},
success: function(response){
var result = response.errors;
if (result == true) {
// given fields are valid
// do some extra stuff here
} else {
// invalid
// do some extra stuff here
}
}
}
});