check_configure_kerio_buisness_mail.tpl 3.5 KB

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