form type ="number" updated value cannot be submitted to server?

Posted November 2, 2016 1.9k views

I am coding a form, one of the input’s type is “number”, so it has the upside and downside arrow to increase or decrease the number, also for some reason it allows the user to enter number in the text as well, so number is entered in the text box, it will be saved and submitted to database, but if i use the arrow to change the number, updated number will not be saved and submitted to server, why is that?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

input type “number” is one of several new types of input supported under HTML5. This type is not supported by older browsers including IE 8 and older. From your description it sounds like the value is changing when you click or enter the number which is the expected functionality.

Why the value isn’t making it through when you submit the form is not entirely clear. For example a form like this:

<form method="POST" action="/somescript.php">
  Quantity (between 1 and 5):
  <input type="number" name="quantity" min="1" max="5">
  <input type="submit" value="Submit">

This form should work to allow you to change the number and the result will be sent as a POST variable to “/somescript.php”. If you are using javascript to validate the form on submission or to gather form fields before submission this is where I would look for a problem.