File manager - Edit - /home/gzbnyc5/pty-app/realstate/public/js/pty.v2.form.basic.validation.js
Back
"use strict"; // Class definition var KTFormAdd = (function () { // Private variables var form; var submitButton; var validation; // Private functions var initValidation = function () { // Init form validation rules. For more info check the FormValidation plugin's official documentation:https://formvalidation.io/ const fields = {}; Array.from(form.querySelectorAll("input.pty-required, select.pty-required")).map((input) => { fields[input.getAttribute("name")] = { validators: { notEmpty: { message: `Required field`, }, }, }; }); validation = FormValidation.formValidation(form, { fields, plugins: { trigger: new FormValidation.plugins.Trigger(), submitButton: new FormValidation.plugins.SubmitButton(), bootstrap: new FormValidation.plugins.Bootstrap5({ rowSelector: ".fv-row", eleInvalidClass: "", eleValidClass: "", }), }, }); }; var handleForm = function () { if (!submitButton) { return; } submitButton.addEventListener("click", function (e) { e.preventDefault(); validation.validate().then(function (status) { if (status == "Valid") { $.ajax({ url: "", dataType: "JSON", type: "POST", data: $(form).serialize(), success: function (response, status, xhr, $form) { if (response.error === 0) { swal.fire({ text: "Thank you! Your information has been stored", icon: "success", buttonsStyling: false, confirmButtonText: "Ok, got it!", customClass: { confirmButton: "btn fw-bold btn-light-primary", }, }); setTimeout(() => { window.location.href = response.redirect; }, 1000); } else { swal.fire({ text: "Sorry, looks like there are some errors detected, please try again.", icon: "error", buttonsStyling: false, confirmButtonText: "Ok, got it!", customClass: { confirmButton: "btn fw-bold btn-light-primary", }, }); } }, error: function (error) { swal.fire({ text: "Sorry, looks like there are some errors detected, please try again.", icon: "error", buttonsStyling: false, confirmButtonText: "Ok, got it!", customClass: { confirmButton: "btn fw-bold btn-light-primary", }, }); }, }); } else { swal.fire({ text: "Sorry, looks like there are some errors detected, please try again.", icon: "error", buttonsStyling: false, confirmButtonText: "Ok, got it!", customClass: { confirmButton: "btn fw-bold btn-light-primary", }, }); } }); }); }; // Public methods return { init: function () { form = document.getElementById("kt_page_add_form"); submitButton = form.querySelector("#kt_page_add_form_submit"); initValidation(); handleForm(); }, }; })(); // On document ready KTUtil.onDOMContentLoaded(function () { KTFormAdd.init(); });
| ver. 1.4 |
Github
|
.
| PHP 8.2.31 | Generation time: 0 |
proxy
|
phpinfo
|
Settings