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?

Jason Butera
  • 2,376
  • 3
  • 29
  • 46
  • I'm having the same problem. Did you come up with a solution or work-around? – Billy Jo Sep 06 '12 at 15:48
  • 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. – mateuscb Feb 10 '14 at 22:21
  • So your concern is about the unobtrusive validation being fire on `keyup` or `blur` every time?? or did i miss something?? – Rohit416 Aug 12 '14 at 11:43
  • I am using it. But not using unobtrusive validation. It works well with regex too. Something must be wrong with your implementation – Md. Tazbir Ur Rahman Bhuiyan Dec 18 '14 at 00:42
  • I am having this exact same problem. Using the [remote] attribute in the model. – Jose A Jan 10 '16 at 14:24

1 Answers1

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

Saineshwar Bageri - MVP
  • 3,851
  • 7
  • 41
  • 47