Question

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

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?


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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.