PATH:
home
/
lab2454c
/
costbloc.com
/
public
/
dist
/
js
/
custom
"use strict"; const vErC = 'error'; const pErC = 'has-validation-error'; const i = document.querySelectorAll('.form-control'); i.forEach(function (inp) { inp.addEventListener('input', function () { // We can only update the error or hide it on inp. // Otherwise it will show when typing. checkValidity(inp, {inErr: false}); }) inp.addEventListener('invalid', function (e) { // prevent showing the default display e.preventDefault() // We can also create the error in invalid. checkValidity(inp, {inErr: true}) }) }); function checkValidity (inp, options) { var inErr = options.inErr; var p = inp.parentNode; var err = p.querySelector(`.${vErC}`) || document.createElement('label'); if (!inp.validity.valid && inp.validationMessage) { err.className = vErC; err.textContent = inp.validationMessage; if (inErr) { if (inp.validity.valueMissing && inp.getAttribute('data-value-missing')) { inp.setCustomValidity(inp.getAttribute('data-value-missing')); err.innerHTML = inp.getAttribute('data-value-missing'); } else if (inp.validity.typeMismatch && inp.getAttribute('data-type-mismatch')) { inp.setCustomValidity(inp.getAttribute('data-type-mismatch')); err.innerHTML = inp.getAttribute('data-type-mismatch'); } else if (inp.validity.patternMismatch && inp.getAttribute('data-pattern')) { inp.setCustomValidity(inp.getAttribute('data-pattern')); err.innerHTML = inp.getAttribute('data-pattern'); } else if (inp.validity.tooShort && inp.getAttribute('data-min-length')) { inp.setCustomValidity(inp.getAttribute('data-min-length')); err.innerHTML = inp.getAttribute('data-min-length'); } else if (inp.validity.tooLong && inp.getAttribute('data-max-length')) { inp.setCustomValidity(inp.getAttribute('data-max-length')); err.innerHTML = inp.getAttribute('data-max-length'); } else if (inp.validity.stepMismatch && inp.getAttribute('data-step-mismatch')) { inp.setCustomValidity(inp.getAttribute('data-step-mismatch')); err.innerHTML = inp.getAttribute('data-step-mismatch'); } else if (inp.validity.rangeUnderflow && inp.getAttribute('data-min')) { inp.setCustomValidity(inp.getAttribute('data-min')); err.innerHTML = inp.getAttribute('data-min'); } else if (inp.validity.rangeOverflow && inp.getAttribute('data-max')) { inp.setCustomValidity(inp.getAttribute('data-max')); err.innerHTML = inp.getAttribute('data-max'); } else if (inp.validity.badInput && inp.getAttribute('data-bad-input')) { inp.setCustomValidity(inp.getAttribute('data-bad-input')); err.innerHTML = inp.getAttribute('data-bad-input'); } else if (inp.validity.customError && inp.getAttribute('data-custom-error')) { inp.setCustomValidity(inp.getAttribute('data-custom-error')); err.innerHTML = inp.getAttribute('data-custom-error'); } p.append(inp, err); p.classList.add(pErC); } else { var hasAttr = inp.getAttribute('data-related'); if (hasAttr) { var el = document.getElementById(hasAttr); var elP = el.parentNode; var elEr = elP.querySelector(`.${vErC}`) el.setCustomValidity(''); elP.classList.remove(pErC); if (elEr != '') { elEr.remove(); } } inp.setCustomValidity(''); p.classList.remove(pErC); err.remove(); } if (typeof(once) != "undefined") { if (once == true) { once = false; $('html, body').animate({ scrollTop: $('.error').offset().top }, 1000); } } } else { inp.setCustomValidity(''); p.classList.remove(pErC); err.remove(); } } // remove select2 error messages $(document).on('change', '.sl_common_bx', function (e) { this.setCustomValidity(''); if ($(e.currentTarget).val() != '') { $('#'+ $(this).attr('id')).parent('div').find('.error').hide(); } else { $('#'+ $(this).attr('id')).parent('div').find('.error').show(); } }); // clearing the input field $(".onblur-clear-this-input").on("blur", function() { const a = document.getElementById(this.id), b = a.closest(".form"); if (b) var c = b.querySelector(".onblur-clear-icon"); c.style.display = 0 == document.getElementById(this.id).value.length ? "none" : "block", c.addEventListener("click", function() { a.value = "", c.style.display = "none" }) }), $(".onblur-clear-this-input").on("focus", function() { const a = document.getElementById(this.id), b = a.closest(".form"); if (b) var c = b.querySelector(".onblur-clear-icon"); c.style.display = "none" });
[-] create-product.min.js
[edit]
[-] refund.js
[edit]
[-] shops.js
[edit]
[-] commission.min.js
[edit]
[-] user.min.js
[edit]
[-] installer.js
[edit]
[-] category.min.js
[edit]
[+]
site
[-] jquery.blockUI.js
[edit]
[-] category.js
[edit]
[-] create-product.js
[edit]
[-] refund.min.js
[edit]
[+]
..
[-] shipping.min.js
[edit]
[-] user.js
[edit]
[-] jquery.blockUI.min.js
[edit]
[-] option.min.js
[edit]
[-] users-activity-list.js
[edit]
[-] attribute.min.js
[edit]
[-] email-configuration.min.js
[edit]
[-] dashboard.js
[edit]
[-] order.min.js
[edit]
[-] delete-modal.js
[edit]
[-] withdrawal.js
[edit]
[-] product-setting.js
[edit]
[-] validation.js
[edit]
[-] vendors.min.js
[edit]
[-] shops.min.js
[edit]
[-] roles.js
[edit]
[-] review.js
[edit]
[-] common.min.js
[edit]
[-] geolocale-suggestion.min.js
[edit]
[-] custom-category.js
[edit]
[-] product.js
[edit]
[-] order-invoice.min.js
[edit]
[-] common.js
[edit]
[-] product_list.js
[edit]
[-] settings.js
[edit]
[-] permission.min.js
[edit]
[-] coupon.js
[edit]
[-] export.js
[edit]
[-] yajra-custom.min.js
[edit]
[-] users-activity-list.min.js
[edit]
[-] finance.min.js
[edit]
[-] geolocale-suggestion.js
[edit]
[-] option.js
[edit]
[-] newsletter.min.js
[edit]
[-] order.js
[edit]
[-] role-permission.js
[edit]
[-] brand.min.js
[edit]
[-] transaction.js
[edit]
[-] popup.min.js
[edit]
[-] validation.min.js
[edit]
[-] templates.min.js
[edit]
[-] attribute.js
[edit]
[-] brand.js
[edit]
[-] app-layout.js
[edit]
[-] preference.js
[edit]
[-] invoice.js
[edit]
[-] order-invoice.js
[edit]
[-] yajra-export.js
[edit]
[-] product-setting.min.js
[edit]
[-] yajra-custom.js
[edit]
[-] installer.min.js
[edit]
[-] invoice.min.js
[edit]
[-] product_list.min.js
[edit]
[-] email-configuration.js
[edit]
[-] custom-category.min.js
[edit]
[-] settings.min.js
[edit]
[-] yajra-export.min.js
[edit]
[-] withdrawal.min.js
[edit]
[-] payment.js
[edit]
[-] preference.min.js
[edit]
[-] roles.min.js
[edit]
[-] finance.js
[edit]
[-] app-layout.min.js
[edit]
[-] permission.js
[edit]
[-] transaction.min.js
[edit]
[-] popup.js
[edit]
[-] order_status.min.js
[edit]
[-] commission.js
[edit]
[-] coupon.min.js
[edit]
[-] shipping.js
[edit]
[-] review.min.js
[edit]
[-] templates.js
[edit]
[-] delete-modal.min.js
[edit]
[-] vendors.js
[edit]
[-] order_status.js
[edit]
[-] dashboard.min.js
[edit]
[-] newsletter.js
[edit]
[-] product.min.js
[edit]
[-] export.min.js
[edit]