What about Form Validation with Alpine.js

2k views Asked by At

I'm discovering the so great Alpine.js framework. But I cannot found how to plug a complete Form validation framework.

For many years I use the complete JqueryValidation, but it needs JQuery ;-)

I tried Ionide.Js but it has not many validators to be pluggable with Laravel.

There are vuelidate and vee-validate for Vue.js but I've no idea how to make them compatible with Alpine.js. Do you ?

So, before start to code something I come to you here to know if I've missed some great receipts for client-side Form validation with Alpine.js with a complete set of rules.

Thanks & cheers

1

There are 1 answers

1
umefarooq On

Jquery has so many plugins and libraries which is very hard to find in Alpine.js I always look for vanilla js package, libraries which i can use with alpine.js. Form validation is missing link in Alpine.js. For form validation i am using Pristine.js vanilla js validation library. You can add your custom validation rules for fields along with available validation rules

https://github.com/sha256/Pristine

Here is simple example Pristine used with alpine.js

https://codepen.io/blcveen/pen/abdpNKW

hope this will help you solve form validation issue.