public function onPreRender($param) { parent::onPreRender($param); $cs = $this->Page->getClientScript(); $cs->registerPradoScript('validator'); // communicate validation status to the client side $value = $this->_isvalid === false ? '0' : '1'; $cs->registerHiddenField($this->getClientID() . '_1', $value); // update validator display if ($control = $this->getValidationTarget()) { $fn = 'captchaUpdateValidatorStatus_' . $this->getClientID(); // check if we need to request a new captcha too if ($this->Page->IsCallback) { if ($control->getVisible(true)) { if (!is_null($this->_isvalid)) { // if the response has been tested and we reach the pre-render phase // then we need to regenerate the token, because it won't test positive // anymore, even if solves correctly $control->regenerateToken(); } } } $cs->registerEndScript($this->getClientID() . '::validate', implode(' ', array('function ' . $fn . '(valid)', '{', ' jQuery(' . TJavaScript::quoteString('#' . $this->getClientID() . '_1') . ').val(valid);', ' Prado.Validation.validateControl(' . TJavaScript::quoteString($control->ClientID) . '); ', '}', '', $this->Page->IsCallback ? $fn . '(' . $value . ');' : '', '', 'jQuery("#' . $control->getClientID() . '").on("keyup", ' . TJavaScript::quoteString('#' . $control->getResponseFieldName()) . ', function() { ', $fn . '("1");', '});'))); } }