|
@@ -4,6 +4,10 @@
|
|
|
</style>
|
|
</style>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
|
+ function is_domain(str) {
|
|
|
|
|
+ const regexp = /^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/i;
|
|
|
|
|
+ return regexp.test(str);
|
|
|
|
|
+ }
|
|
|
function checkInput (domain, pid) {
|
|
function checkInput (domain, pid) {
|
|
|
var xhttp = new XMLHttpRequest();
|
|
var xhttp = new XMLHttpRequest();
|
|
|
var success = false;
|
|
var success = false;
|
|
@@ -47,17 +51,31 @@
|
|
|
$(customFields[0]).val(''); // domain
|
|
$(customFields[0]).val(''); // domain
|
|
|
$(checkBox[0]).removeClass('checked'); // checkbox
|
|
$(checkBox[0]).removeClass('checked'); // checkbox
|
|
|
$(customFields[0]).blur(function () {
|
|
$(customFields[0]).blur(function () {
|
|
|
- checkInput( $(customFields[0]).val().trim(), {$productinfo['pid']});
|
|
|
|
|
|
|
+ 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 () {
|
|
$(customFields[0]).on('input', function () {
|
|
|
- setTimeout(function () {
|
|
|
|
|
- checkInput( $(customFields[0]).val().trim(), {$productinfo['pid']});
|
|
|
|
|
- }, 1);
|
|
|
|
|
|
|
+ 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 () {
|
|
$(checkBoxHelper[0]).click(function () {
|
|
|
- setTimeout(function () {
|
|
|
|
|
- checkInput( $(customFields[0]).val().trim(), {$productinfo['pid']});
|
|
|
|
|
- }, 1);
|
|
|
|
|
|
|
+ if (is_domain($(customFields[0]).val().trim())) {
|
|
|
|
|
+ setTimeout(function () {
|
|
|
|
|
+ checkInput( $(customFields[0]).val().trim(), {$productinfo['pid']});
|
|
|
|
|
+ }, 1);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.log('onClick');
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
</script>
|
|
</script>
|