Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

input type number in html 5 is not working? [closed]

Tags:

html

<form name="form" method="get" action="" >
Number : 
<input type="number" name="num" id="num" min="1" max="5" required="required"/> <br/>
Email :
<input type="email" name="email" id="email"  required="required"/> <br />
<input type="submit" name="submit" id="submit" value="submit"  />
</form>

It is taking alphabets too on submitting the form. No error messages are generated Number type is not working.

like image 825
neha thamman Avatar asked Sep 12 '12 06:09

neha thamman


1 Answers

This is how you use the input type number in HTML5:

<input type="number" name="cost">

Here is a working example of the input type number.

If you want to add validation try this:

<input type="number" pattern="[0-9]*" name="cost">

Here is a working example of the pattern attribute.

Note: Both the input type number and the pattern attribute have limited browser support.

like image 90
Scott Bartell Avatar answered Oct 12 '22 18:10

Scott Bartell