Anybody Know of any jQuery Mask Plugin that works with MVC Unobtrusive Validation?
Asked Answered
B

1

6

I've always used the following mask input plugin in my ASP.Net applications:

http://digitalbush.com/projects/masked-input-plugin/

Unfortunately, this doesn't play well with MVC unobtrusive validation. Validation fires on every keyup which is annoying. Plus, a regex attribute always fails when the input loses focus because it reads the mask as the actual user input before the mask control clears it.

Anybody come across a masked textbox solution that plays well with MVC validation?

Bibliotaph answered 10/7, 2012 at 13:38 Comment(5)
I'm having the same problem. Did you come up with a solution or work-around?Anishaaniso
I know that sometimes we are asked to create things and don't have much of a choice. But I just wanted to comment that Masks and Unobtrusive validation are really mutually exclusive, the idea with unobtrusive is that it doesn't limited the usability in anyway, and simply warns the user that the input is invalid. If you have a mask, you really don't need to have unobtrusive validation, since the input is already limited by the mask. I would consider only using on of these methods of validations.Harless
So your concern is about the unobtrusive validation being fire on keyup or blur every time?? or did i miss something??Corwun
I am using it. But not using unobtrusive validation. It works well with regex too. Something must be wrong with your implementationGramercy
I am having this exact same problem. Using the [remote] attribute in the model.Recountal
G
0

Sir you can use Bootstrap placeholder for showing mask Link for example

<div class="input-group">
  <span class="input-group-addon" id="basic-addon1">@</span>
  <input type="text" class="form-control" placeholder="Username" aria-describedby="basic-addon1">
</div>

enter image description here

Gonophore answered 14/8, 2015 at 5:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.