arame3333
arame3333

Reputation: 10193

Jquery inputmask not allowing integer input

I am using the jquery inputmask library to control the user input for my form. See https://github.com/RobinHerbots/jquery.inputmask

All I want is to ensure the user enters an integer 0-99. So in my MVC application I have;

@Html.TextBoxFor(model => model.Contract.ContractPeriodInWeeks, 
            new { style = "width:30px",  @data_inputmask="'mask': '99'" })

Yet this mask has no effect. What am I doing wrong?

Upvotes: 0

Views: 2011

Answers (1)

Nydieven
Nydieven

Reputation: 38

Ok so i've been using inputmask in my asp mvc project too, and i got the same problem.

I've tried many things and managed to get it to work by adding it in a javascript right:

@Html.TextBoxFor(model => model.Contract.ContractPeriodInWeeks, 
        new { style = "width:30px" })
<script type="text/javascript">
    $('#Contract_ContractPeriodInWeeks').inputmask('99');
</script>

Although i still don't know why you can't use input mask in the object HtmlAttributes, this should do the trick.

Hope this helps.

Upvotes: 1

Related Questions