libreform / wp-libre-form

Easy native HTML5 forms for WordPress. Version 1.5 is unmaintained, but works without issue. 2.0 has been rewritten from the ground, and can be found at https://github.com/libreform/libreform
https://wordpress.org/plugins/wp-libre-form
GNU General Public License v3.0
67 stars 27 forks source link

Parse html form and create validation rules #136

Closed luizbills closed 5 years ago

luizbills commented 5 years ago

We can use some lib like https://github.com/Rct567/DomQuery to parse the HTML and create some validation rules.

e.g: <input type="email" maxlength="20" required>

this field is required (already implemented) and must be an valid email with 20 chars or less.

rask commented 5 years ago

You mean that the HTML would be parsed and backend (PHP) field validation would be built upon those HTML rules? Are there some rules which are not covered by the browser validation API (https://caniuse.com/#feat=form-validation)?

luizbills commented 5 years ago

Are there some rules which are not covered by the browser validation API?

Maybe, idk. But we can use the native html validation rules to create a basic backend validator. Other rules can be implemented using a special field attribute (something like data-wplf-validate="...").

k1sul1 commented 5 years ago

This seems stale, and IMO advanced validation is not in the scope of this project. Users can add their custom validators.

If anyone implements something like this, implement it as a standalone plugin, and I'll gladly feature it on the plugins page. I'm not willing to implement it myself, DOM operations & PHP make me want to go KMS.