mcintyre321 / FormFactory

MVC5, Core or standalone - Generate rich HTML5 forms from your ViewModels, or build them programatically
http://formfactoryaspmvc.azurewebsites.net/
MIT License
304 stars 102 forks source link

PropertyVm of Int32 does not render as an HTML5 input of type 'number' #77

Closed jeremytbrun closed 5 years ago

jeremytbrun commented 5 years ago

Is there a reason why any PropertyVm's that are of type Int32 are rendered as only as an input of type 'text' according to...

https://github.com/mcintyre321/FormFactory/blob/master/FormFactory/Views/Shared/FormFactory/Property.System.Int32.cshtml

Why don't these get rendered as type 'number' in HTML5? It'd make the client side validation work right out of the box to only let the user submit a numeric value.

Otherwise is there a way you'd recommend programmatically creating my PropertyVm so that client side validation works to limit it to only numeric values?

mcintyre321 commented 5 years ago

Not sure what the browser support was like when I wrote that view in 2011! That or I hadn't heard about it.

I think it's probably not a breaking change, so if you want please update the view and send a PR. FF is an ongoing work any contributions and improvements are very welcome!

If not, you can override the view in your own project (FF checks your local views directory before reading the embedded ones).

Or you can put a Regex validation attribute on it to allow only integer characters.

On Fri, 1 Mar 2019, 19:45 Jeremy Brun, notifications@github.com wrote:

Is there a reason why any PropertyVm's that are of type Int32 are rendered as only as an input of type 'text' according to...

https://github.com/mcintyre321/FormFactory/blob/master/FormFactory/Views/Shared/FormFactory/Property.System.Int32.cshtml

Why don't these get rendered as type 'number' in HTML5? It'd make the client side validation work right out of the box to only let the user submit a numeric value.

Otherwise is there a way you'd recommend programmatically creating my PropertyVm so that client side validation works to limit it to only numeric values?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mcintyre321/FormFactory/issues/77, or mute the thread https://github.com/notifications/unsubscribe-auth/AAQ0-nQo4MB2wu-9q577Xbq5IE9sXR5rks5vSYNwgaJpZM4bZsVJ .

nickcoad commented 5 years ago

I've submitted a PR for this, I considered also changing double and decimal, but wasn't sure if that would be appropriate. Open to your thoughts on this.