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,761
  • 16
  • 33
  • 49
  • 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,753
  • 3
  • 30
  • 45
0

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

CaptainCarl
  • 3,411
  • 6
  • 38
  • 71
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,915
  • 9
  • 39
  • 60
0

You can use as following if your working with HTML 5

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