public static function print_notification_email_field() { $field_name = 'notification_email'; printf('<div class="nelio-sect"><input type="text" id="%1$s" name="nelioab_settings[%1$s]" style="max-width:400px;width:100%%;" value="%3$s" placeholder="%4$s" %2$s></div>', $field_name, self::get_basic_details(), esc_html(NelioABSettings::get_notification_email()), sprintf(__('Default: %s', 'nelioab'), esc_html(NelioABAccountSettings::get_email()))); ?> <div class="the-descr" style="display:none;"><span class="description"><?php printf(__('If you type an e-mail address, all Nelio A/B Testing notifications will be sent to both the new address and «%s».', 'nelioab'), NelioABAccountSettings::get_email()); ?> </span></div> <script type="text/javascript"> (function($) { var mail = $('#<?php echo $field_name; ?> '); var form = $('#nelioab-settings'); var save; function validateMail() { var x = mail.attr('value'); if ( x.length == 0 ) return true; var atpos = x.indexOf('@'); var dotpos = x.lastIndexOf('.'); if (atpos< 1 || dotpos<atpos+2 || dotpos+2>=x.length) return false; return true; } function control() { if ( validateMail() ) { mail.removeClass('error'); save.removeClass('disabled'); form.unbind('submit', returnFalse); } else { mail.addClass('error'); save.addClass('disabled'); form.on('submit', returnFalse); } } function returnFalse() { return false; } mail.on('keyup focusout', control); $(document).ready(function() { save = $('#submit'); control(); }); })(jQuery); </script> <?php }