| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <style>
- .has-error { background-color: #f003 !important; }
- .has-success { background-color: #0f03 !important; }
- </style>
- <script>
- function is_domain(str) {
- console.log(str);
- const regexp = /^[a-z0-9]+\.[a-z]$/;
- return regexp.test(str);
- }
- function checkInput (domain, pid) {
- var xhttp = new XMLHttpRequest();
- var success = false;
- xhttp.onreadystatechange = function() {
- if (this.readyState == 4 && this.status == 200) {
- if( this.responseText.trim() == 'yes') {
- console.log(this.responseText);
- $(customFields[0]).addClass('has-success');
- $(customFields[0]).removeClass('has-error');
- $("#hint").text('');
- if ($(checkBox[0]).hasClass('checked')) {
- $("#btnCompleteProductConfig").prop("disabled",false);
- } else {
- $("#btnCompleteProductConfig").prop("disabled",true);
- $("#hint").text('Bitte akzeptieren Sie die erweiterten Nutzungsbedingungen!');
- }
- } else if ( this.responseText.trim() == 'invalid') {
- console.log(this.responseText);
- $(customFields[0]).addClass('has-error');
- $(customFields[0]).removeClass('has-success');
- $("#btnCompleteProductConfig").prop("disabled",true);
- $("#hint").text('Ungültiger Domainname!');
- } else {
- console.log(this.responseText);
- $(customFields[0]).addClass('has-error');
- $(customFields[0]).removeClass('has-success');
- $("#hint").text('Domain ' + $(customFields[0]).val() + ' nicht verfügbar!');
- $("#btnCompleteProductConfig").prop("disabled",true);
- }
- }
- };
- xhttp.open("GET", "modules/servers/kerioEmail/kerioDomainAvailable.php?domain=" + domain + '&pid=' + pid, true);
- xhttp.send();
- };
- jQuery(document).ready(function(){
- customFields = $("*[id^='customfield']");
- checkBoxHelper = $("*[class^='iCheck-helper']");
- checkBox = $("*[id^='iCheck-customfield']")
- $("#btnCompleteProductConfig").prop("disabled",true);
- $(customFields[0]).val(''); // domain
- $(checkBox[0]).removeClass('checked'); // checkbox
- $(customFields[0]).blur(function () {
- if (is_domain($(customFields[0]).val().trim())) {
- setTimeout(function () {
- checkInput( $(customFields[0]).val().trim(), {$productinfo['pid']});
- }, 1);
- } else {
- console.log('onBlur');
- }
- });
- $(customFields[0]).on('input', function () {
- if (is_domain($(customFields[0]).val().trim())) {
- setTimeout(function () {
- checkInput( $(customFields[0]).val().trim(), {$productinfo['pid']});
- }, 1);
- } else {
- console.log('onInput');
- }
- });
- $(checkBoxHelper[0]).click(function () {
- if (is_domain($(customFields[0]).val().trim())) {
- setTimeout(function () {
- checkInput( $(customFields[0]).val().trim(), {$productinfo['pid']});
- }, 1);
- } else {
- console.log('onClick');
- }
- });
- });
- </script>
|