jbonfardeci / ShockoutForms

SharePoint + Knockout MVVM forms - an InfoPath killer
32 stars 8 forks source link

How to add is dirty flag ? #19

Closed leolorenzoluis closed 8 years ago

leolorenzoluis commented 8 years ago

I would like the form to not show that it already has errors and required when it first loaded. I would prefer if it can be when the user started submitting the form. An example is this http://www.knockmeout.net/2011/05/creating-smart-dirty-flag-in-knockoutjs.html

Could you guide me where to start?

jbonfardeci commented 8 years ago

Personally I wouldn’t recommend this since users typically would want to know what fields are required before pressing the submit button. I know our uses would be irritated. However, one idea off the top of my head is to override the CSS for elements with the required attribute by adding a class name such as ‘clean’ to the parent form element.

You could set the border color to normal (whatever that is) by targeting .spform.clean input[required], .spform.clean select[required] { border-color: #ccc; }.

Attach a mousedown event handler to the Submit button that removes the clean class from .spform. This will revert the red borders around the input fields. There will be a little more to it but this is the gist of a simple approach.

On May 17, 2016, at 1:41 PM, leolorenzoluis notifications@github.com wrote:

I would like the form to not show that it already has errors and required when it first loaded. I would prefer if it can be when the user started submitting the form. An example is this http://www.knockmeout.net/2011/05/creating-smart-dirty-flag-in-knockoutjs.html http://www.knockmeout.net/2011/05/creating-smart-dirty-flag-in-knockoutjs.html Could you guide me where to start?

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/jbonfardeci/ShockoutForms/issues/19