Report this

What is the reason for this report?

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

Posted on November 2, 2016

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?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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">
</form>

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.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.