>>>What is a simple way to format an ASP.NET textbox for a number where user would enter the labor hours (e.g. 1.0, 2.25, 10.50 and so on).
>>>When I add to the ASP.Textbox type="number" it would not allow a decimal.
>>>What am I missing?
>>>TIA
>>>
>>>UPDATE: Found this page with fairly simple javascript to allow only numbers with decimals.
>>>
>>>
http://www.dotnetspark.com/kb/5510-accept-only-numeric-and-decimal-values-textbox.aspx>>
>>Couple of thoughts:
>>You could make this more generic by binding to all number types by using '$('input[type="number"]').----'
>>You probably still need validation (user can, for example, paste in a value). Maybe a regex pattern:
<input type="number" step="0.01" pattern="^\d+(\.)\d{2}$" required/>
(That's limiting to 2 decimal places which may not be what you want)
>
>Viv, could you please clarify the syntax of "required" above? By itself, when I enter it in the input control (asp:textbox) it does not work. So I must be missing something. And it seems that without this "required" the pattern you specified does not work. That is, I copied the pattern exactly as in your example, but I can enter more than 2 decimals.
>TIA.
Required and pattern are html5 attributes for handling form validation. See
http://www.html5rocks.com/en/tutorials/forms/html5forms/ for more info.