jwaliszko / ExpressiveAnnotations

Annotation-based conditional validation library.
MIT License
351 stars 123 forks source link

Hidden Input Dynamic #161

Closed mauricioferrazs closed 7 years ago

mauricioferrazs commented 7 years ago

Is there any way to hide or disable a field based on another equal to the requiredif?

Thanks

jwaliszko commented 7 years ago

If I understand you correctly, there is such a possibility, but not out of the box. You could make a use of eavalid event + some additional coding to achieve that.

Instead of disabling non-required fields, some users prefer hiding, some other annotating with asterisk, etc. In the MVC sample I've provided examplary solution to such use cases. Take a look at Home.cshtml view - annotateRequiredFields() function in particular.

In addition, to grab more outlook, go through similar questions which already have been asked before, i.e. https://github.com/jwaliszko/ExpressiveAnnotations/issues/121, and updated https://github.com/jwaliszko/ExpressiveAnnotations/issues/139.

mauricioferrazs commented 7 years ago

Thanks jwaliszko. I will take a look that.

jwaliszko commented 7 years ago

Related section added to the documentation: https://github.com/jwaliszko/ExpressiveAnnotations#can-i-decorate-conditionally-required-fields-with-asterisks