-1

Is there any way to have a feature like a Numeric textbox in MVC which has all the validations in place(Do not want to use Kendo as it has all kinds of Validation probblems) ?

Reet
  • 55
  • 6
  • Have you looked for [html numeric textbox](https://www.google.com/search?q=html%20numeric%20textbox)? This is not mvc specific. – Igor Jul 22 '16 at 19:47

3 Answers3

1

You can validate with javascript like this:

function isNumber(n) {
    return !isNaN(parseFloat(n)) && isFinite(n);
}

from here

Community
  • 1
  • 1
Guilherme Holtz
  • 474
  • 6
  • 19
  • Thanks for the response but Currency also involves checking for decimals and while displaying it should format with commas. Ex 100,000$ – Reet Jul 22 '16 at 19:47
  • For currency you can try these libs: [money.js](http://openexchangerates.github.io/money.js) or [numeral.js](http://numeraljs.com) – Guilherme Holtz Jul 22 '16 at 19:51
0

You can try this, The third parameter are your Html attributes.

@Html.TextBox("Age", null, new {type ="number", min="1" max="5", id="age"})
Kld
  • 6,970
  • 3
  • 37
  • 50
0

You could set the input type to number

@Html.TextBoxFor(model => model.numberProperty, new { @type = "number" })
Broom
  • 596
  • 2
  • 18