0

I have a form like this. I tried to change text type="text to digit" but it didn't work. I want to accept only numbers.

<tr>
    <td width="100">
        <font face="arial" size="2">* Age</font>
    </td>
    <td width="250">
        <input id="your_age" name="your_age" type="digit" />
    </td>
Lee Taylor
  • 7,155
  • 14
  • 29
  • 44
  • Try to avoid using `face` attribute etc. Get into the habit of using style/css. – Lee Taylor Apr 15 '13 at 13:47
  • Did you google "html input number only" and find that [the top three results](https://www.google.co.uk/search?q=html+input+number+only) are on SO? – George Apr 15 '13 at 13:48

4 Answers4

0

You can't do that using HTML tags if you not using HTML5. You need to do some sort of validation using javascript or php for accepting only numbers/digit.

chandresh_cool
  • 11,600
  • 3
  • 27
  • 44
0

You can use <input type="number">. You may want to check if it's a number afterwards with PHP too though.

CaptainCarl
  • 3,183
  • 5
  • 32
  • 67
0

You are talking about a client-side verification, which has nothing to do with PHP.

In HTML5 you can use type="number"

kgautron
  • 7,518
  • 8
  • 37
  • 59
0

You can use as following if your working with HTML 5

 <input type="number" />
sandy
  • 1,096
  • 1
  • 7
  • 17