I have been writing few series of new HTML5 input types and this is another post on same series. In this post I am going to explain Number input types. The number type is for numeric values. When you use number input type it will have spinner with up and down arrow and with the help of this you can increase or decrease of value.
There are four attributes of Number input types.
So now we know all attributes for number input types it is time for writing some code now. I am going to use same code for that I was using for that. Following is a code for that.
@{ ViewBag.Title = "Home Page"; } <h2>@ViewBag.Message</h2> <p> To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>. </p> <form action="" method="post"> <label for="numberInput">Select Number:</label> <input id="numberInput" name="numberInput" type="number" min="1" max="10"/> </form>
Here in the above code you can see I have specified min value is 1 and max value is 10. So it can have any values between 1 to 10. So let’s run that code in browser.
As you can see it is displaying output as expected. Please note that number input type are supported in following browsers.
For other browsers that are not supporting number input type it will work as normal input type. That’s it. Hope you like it. Stay tuned for more.. Till than happy programming..
Tags: #ASP.NET, MVC 3.0, HTML5,