The New Way to Build with AI! Introducing ReUI — the developer platform for agentic UI with shadcn/ui
Browse ReUI Pro

Laravel and FormValidator


HI
I'm about to start a project with Metronic 8.2.3 and Laravel 10. As soon as it was installed I ran some tests on the validation of the Users form. In my case the validation is managed by Livewire. I would like it to be handled by the FormValidator library instead. Can you kindly give me a simple example? Thank you


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (4)

 
Deleted comment
 
Deleted comment

You can use FormValidator in Metronic 8.2.3 with Laravel 10 by integrating it with your user form.

Here's a simple example:
$('#userForm').validate({
rules: {
name: { required: true, minlength: 3 },
email: { required: true, email: true },
password: { required: true, minlength: 6 }
},
messages: {
name: "Please enter at least 3 characters",
email: "Enter a valid email address",
password: "Password must be at least 6 characters long"
}
});

This ensures client-side validation before submitting the form. For more updates, visit wormzoneapk.com.


 
Deleted comment

Hi

To use FormValidation with Livewire during form submission, you can try these:

Ensure your Livewire component is set up to handle form submission. Use the wire:submit directive to point to the method that will process the form.

In your JavaScript file, initialize FormValidation on the form element. You’ll need to specify the form ID and the validation rules according to the FormValidation documentation.

To integrate FormValidation with Livewire, you can listen for the form’s submit event in JavaScript and manually trigger Livewire’s form submission only if the form passes validation. Here’s a sample JavaScript snippet:

document.addEventListener("livewire:load", function () {
const formValidation = FormValidation.formValidation(
document.getElementById("your-form-id"),
{
// Your validation rules
}
);

document.getElementById("your-form-id").addEventListener("submit", function (e) {
e.preventDefault();

formValidation.validate().then(function(status) {
if (status === "Valid") {
window.livewire.emit("submitForm");
}
});
});
});


In your Livewire component, create a method named submitForm (or whatever you named it in the JavaScript emit function) to handle the form submission after validation.

Optionally, you can also include server-side validation in your Livewire method to ensure data integrity, even if the client-side validation is bypassed.


 
Deleted comment

Hi James Herris

Sorry for the delay in response. When you mention the FormValidator library, are you referring to a specific Laravel package for form validation or the FormValidation JavaScript library? Knowing which library you're referring to will help provide a more accurate example for your form validation setup.



Thanks for reply.
I apologize for the inaccuracy. I am referring to the FormValidation JavaScript library


 
Deleted comment
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
buy metronic keenthemes mega bundle

ReUI

Open-source React components, blocks and templates built on shadcn/ui and Tailwind CSS by Keenthemes.