Introducing ReUI:Open-source UI components and apps built with React, Next.js and Tailwind CSS
Browse ReUI

Re Validation form (Metronic 8.2- html)


Hello,

How can the form validation function be called again in Metronic 8.2? Because when an item in the form is removed or added by hide() and show(), the validation on these items does not work correctly.

When an item is hidden, the class "fv-row" is removed from the div.
When an item is show, the class "fv-row" is added to div.

Despite what I have mentioned, the form validation still does not work correctly on the new changes and seems to require being called again.

I would appreciate your guidance. Thank you!


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (2)


For kids, there's the online game bitlife Life Simulator, which works on Samsung, iPhone, iPad, and other Android and Apple devices.



Hi,

Please try to refer to the official docs of the plugin https://formvalidation.io/ and refer to the below code:


// Assume `form` is the form element, and `validator` is the FormValidation instance
const form = document.querySelector("#yourFormId");
const validator = FormValidation.formValidation(form, {
fields: {
// Define your fields and their validation rules
fieldName: {
validators: {
notEmpty: {
message: "This field is required",
},
},
},
},
plugins: {
trigger: new FormValidation.plugins.Trigger(),
bootstrap: new FormValidation.plugins.Bootstrap(),
},
});

// When an element is shown
function onElementShown() {
// Update FormValidation to revalidate the shown element
validator.addField("fieldName", {
validators: {
notEmpty: {
message: "This field is required",
},
},
});
}

// When an element is hidden
function onElementHidden() {
// Update FormValidation to ignore the hidden element
validator.disableValidator("fieldName");
}


Regards,
Sean


Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(