Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What patterns do you use for Form Validation in complex forms involving many sub-views

Validation in Backbone

I'm building some a complex form using Backbone. If I was to categorize the types of views I have I would say I have Model-Views and Collection-Views. Where Model views represent single entity information and collection-views represent repeating forms ( to create multiple Logins for example ).

I am using the model binder plugin for two way binding and the form is working fine however I haven't implemented any client side validation. I was thinking going the model validation route however I realised that the reason I want client side validation is to show messages and inform the user about the more common mistakes and not to actually ensure the integrity of the data, as that is done by the server.

I would be interested in hearing any patterns/ideas as to which approach is good.

I already have jquery validation if this is any help.

like image 482
Daniel Avatar asked Nov 13 '22 16:11

Daniel


1 Answers

My own solution for current project is jQuery.Validate plugin for validating fields and custom Form view for processing form submit and handling server errors.

Validation plugin is far from perfect in terms of documentation, but once you understand from its source what's happening under the hood, things improve greatly. It's really flexible, gets things done and is easy to extend.

Can't say I'm happy with amount of custom code that has be written for Form view and overall abstraction level of solution, but this is the best thing I were able to find out for today.

like image 105
Alexander Lebedev Avatar answered Nov 15 '22 07:11

Alexander Lebedev