protected function _getElementHtml($element) { $element->setData('onchange', "apiValidation(this.form, this);"); $url = $this->getUrl('*/connector/ajaxvalidation'); $element->setData('after_element_html', "\n <script>\n document.observe('dom:loaded', function(){\n apiValidation();\n\n });\n function apiValidation(form, element) {\n var api_user = \$('connector_transactional_emails_credentials_api_username');\n var api_password = \$('connector_transactional_emails_credentials_api_password');\n var reloadurl = '{$url}';\n var encoded = btoa(api_password.value);\n new Ajax.Request(reloadurl, {\n method: 'post',\n parameters: {'api_username' : api_user.value, 'api_password' : encoded},\n onComplete: function(transport) {\n Element.hide('loadingmask');\n if(transport.responseText == '\"Credentials Valid.\"'){\n api_user.setStyle({\n fontWeight: 'bold',\n color: 'green' ,\n background: 'transparent url(\"" . $this->getSkinUrl('images/success_msg_icon.gif') . "\") no-repeat right center'\n })\n }else{\n api_user.setStyle({\n fontWeight: 'bold',\n color: 'red',\n background: 'transparent url(\"" . $this->getSkinUrl('images/error_msg_icon.gif') . "\") no-repeat right center'\n });\n\n }\n }\n });\n\n return false;\n }\n\n </script>\n "); return parent::_getElementHtml($element); }