One of the requirements is that for buy() and sell(), if I do not put a positive integer for the text box for the number of stocks, my code should send a 400 message. I coded this in:

<input autocomplete="off" autofocus class="form-control" name="shares" placeholder="Shares" type="number" step="1" min="1"/>

This code DOES reject negative, zero, and non-integer inputs. However, when a user tries to enter one of these types, HTML sends to my server 200. Is there a way to dictate this message to send 400 instead?


I don't know of any way to send a 400. And I totally agree that this checking should be done in the UI for a better user-experience. This class is not about UX, however, and the specification for buy says:

Require that a user input a number of shares, implemented as a text field whose name is shares. Render an apology if the input is not a positive integer.

Therefore, best to put error checking in the buy function.

  • what is UI and UX? Jul 29 '18 at 23:36
  • 1
    UI is User Interface (the screen). UX is User eXperience (how the user interacts with the screen). Jul 29 '18 at 23:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .