0

From CS50's Problem Set 9 specification:

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.

I'm validating whatever number of shares the user inputs on the server because they can just edit the HTML, but why would I implement it as a text field when I'm trying to get a positive integer? Shouldn't I be using <input type="number" name="shares" placeholder="Shares" min=1 required> instead? It makes it easier for users and harder to send the wrong value. Can I use it? or will it be wrong?

1 Answer 1

1

As you probably have already learned, problems must conform to the spec, full stop. I totally agree that the input should be validated in the HTML; it is better UI/UX. You could always run check50 to see what will happen. If I recall properly, it will pass as long as the validation is done in buy, but you shouldn't take my word for it, since I don't give out the grade :)

You must log in to answer this question.

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