wyyl/resources/beike/shop/default/js/bootstrap-validation.js

29 lines
773 B
JavaScript

/*
* @copyright 2022 beikeshop.com - All Rights Reserved.
* @link https://beikeshop.com
* @Author pu shuo <pushuo@guangda.work>
* @Date 2022-08-17 17:39:14
* @LastEditTime 2022-09-16 20:56:42
*/
// Example starter JavaScript for disabling form submissions if there are invalid fields
$(function () {
var forms = document.querySelectorAll(".needs-validation");
// Loop over them and prevent submission
Array.prototype.slice.call(forms).forEach(function (form) {
form.addEventListener(
"submit",
function (event) {
if (!form.checkValidity()) {
event.preventDefault();
event.stopPropagation();
}
form.classList.add("was-validated");
},
false
);
});
});