Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Only allow Numbers in input Tag without Javascript

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>
like image 438
Yusuf Avatar asked Sep 21 '12 15:09

Yusuf


1 Answers

Try this with the + after [0-9]:

input type="text" pattern="[0-9]+" title="number only"
like image 133
nickko Avatar answered Sep 25 '22 12:09

nickko