Only allow Numbers in input Tag without Javascript

asp.net-mvc-3, html, input

Solution

Though it's probably suggested to get some heavier validation via JS or on the server, HTML5 does support this via the pattern attribute.

<input type= "text" name= "name" pattern= "[0-9]"  title= "Title"/>

Problem

I am fairly new. I am creating a webpage that ask a user for their ID. I want it to be a required field and only allow numbers. I appreciate if you lead me in the correct direction. this is what I have so far. ``` <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %> <!DOCTYPE html> <html> <head runat="server"> <title>Search</title> </head> <body> <div> <table align="center"> <tr> <td class="label"> Enter ID: </td> <td> <input type="text" name="UserId" id="UserId" /> </td> </tr> </table> </div> </body> </html> ```

Original source

Related problems