0

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?

1 Answer 1

0

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.

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

You must log in to answer this question.

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