Eddie Fiorentine
Eddie Fiorentine

Reputation: 45

MVC5 Text Box Input Mask With Placeholder

I'm trying to implement an Input Mask to force a two character entry. If the field is empty, I would like to display a placeholder. This works fine with fields that I do not mask the input, but it does not seem to work with masked inputs. Any other solutions? Here is a snippet of the field:

<dd style="display: none" id="stateEditor">@Html.TextBoxFor(Model => Model.State, new { mask = "aa", htmlAttributes = new { placeholder = "NJ" } })</dd>

Any tips would be appreciated.

Upvotes: 0

Views: 6395

Answers (1)

Nikolai
Nikolai

Reputation: 306

You don't need to set placeholder in htmlAttributes. Set placeholder the same as mask attribute. hope, it will help.

<dd style="display: none" id="stateEditor">@Html.TextBoxFor(m => m.State, new { mask = "aa", placeholder = "NJ" })</dd>

Upvotes: 1

Related Questions