I'm working on a form with ASP.NET MVC and am trying to figure out how best to implement input masking (e.g. for phone number or US zip code). Are there any commonly accepted approaches here for the data types I should use in my model. This question suggests to use a long for phone number and using a DisplayFormat
attribute on the model field but it seems to conflict with validation. I don't really mind converting from one type in my view model to another type in my data models, but would like to chose an approach which sits well with jQuery unobtrusive validation.
相关问题
- MVC-Routing,Why i can not ignore defaults,The matc
- parameters in routing do not work MVC 3
- There is no ViewData item with the key 'taskTy
- TextBoxFor decimal
- Install ASP.NET 5.0 version of System.ServiceModel
相关文章
- How to get a list of connected clients on SignalR
- How do you redirect to the calling page in ASP.NET
- Change color of bars depending on value in Highcha
- The program '[4432] iisexpress.exe' has ex
- ASP.Net MVC 4 Bundles
- How to get server path of physical path ?
- Cannot implicitly convert Web.Http.Results.JsonRes
- entity type has no key defined - Code first
I personally like using the Masked Input Plugin. You set up the mask in JavaScript, so it is unobstrusive, but it does not use
data-*
attributes.In the project I'm working on, we do use
long
to store the phone number, which personally I do not like.