check_configure_kerio_buisness_mail.tpl 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <style>
  2. .has-error { background-color: #f003 !important; }
  3. .has-success { background-color: #0f03 !important; }
  4. </style>
  5. <script>
  6. function is_domain(str) {
  7. const regexp = /^[a-z0-9]/;
  8. return regexp.test(str);
  9. }
  10. function checkInput (domain, pid) {
  11. var xhttp = new XMLHttpRequest();
  12. var success = false;
  13. xhttp.onreadystatechange = function() {
  14. if (this.readyState == 4 && this.status == 200) {
  15. if( this.responseText.trim() == 'yes') {
  16. console.log(this.responseText);
  17. $(customFields[0]).addClass('has-success');
  18. $(customFields[0]).removeClass('has-error');
  19. $("#hint").text('');
  20. if ($(checkBox[0]).hasClass('checked')) {
  21. $("#btnCompleteProductConfig").prop("disabled",false);
  22. } else {
  23. $("#btnCompleteProductConfig").prop("disabled",true);
  24. $("#hint").text('Bitte akzeptieren Sie die erweiterten Nutzungsbedingungen!');
  25. }
  26. } else if ( this.responseText.trim() == 'invalid') {
  27. console.log(this.responseText);
  28. $(customFields[0]).addClass('has-error');
  29. $(customFields[0]).removeClass('has-success');
  30. $("#btnCompleteProductConfig").prop("disabled",true);
  31. $("#hint").text('Ungültiger Domainname!');
  32. } else {
  33. console.log(this.responseText);
  34. $(customFields[0]).addClass('has-error');
  35. $(customFields[0]).removeClass('has-success');
  36. $("#hint").text('Domain ' + $(customFields[0]).val() + ' nicht verfügbar!');
  37. $("#btnCompleteProductConfig").prop("disabled",true);
  38. }
  39. }
  40. };
  41. xhttp.open("GET", "modules/servers/kerioEmail/kerioDomainAvailable.php?domain=" + domain + '&pid=' + pid, true);
  42. xhttp.send();
  43. };
  44. jQuery(document).ready(function(){
  45. customFields = $("*[id^='customfield']");
  46. checkBoxHelper = $("*[class^='iCheck-helper']");
  47. checkBox = $("*[id^='iCheck-customfield']")
  48. $("#btnCompleteProductConfig").prop("disabled",true);
  49. $(customFields[0]).val(''); // domain
  50. $(checkBox[0]).removeClass('checked'); // checkbox
  51. $(customFields[0]).blur(function () {
  52. if (is_domain($(customFields[0]).val().trim())) {
  53. setTimeout(function () {
  54. checkInput( $(customFields[0]).val().trim(), {$productinfo['pid']});
  55. }, 1);
  56. } else {
  57. console.log('onBlur');
  58. }
  59. });
  60. $(customFields[0]).on('input', function () {
  61. if (is_domain($(customFields[0]).val().trim())) {
  62. setTimeout(function () {
  63. checkInput( $(customFields[0]).val().trim(), {$productinfo['pid']});
  64. }, 1);
  65. } else {
  66. console.log('onInput');
  67. }
  68. });
  69. $(checkBoxHelper[0]).click(function () {
  70. if (is_domain($(customFields[0]).val().trim())) {
  71. setTimeout(function () {
  72. checkInput( $(customFields[0]).val().trim(), {$productinfo['pid']});
  73. }, 1);
  74. } else {
  75. console.log('onClick');
  76. }
  77. });
  78. });
  79. </script>