Is it important to verify data as well as HTML5 checks?

Here’s an example from the Programming Elm book. It disables the form button for an empty string. It seems to work fine without the duplicate check for empty strings (it won’t post when pressing the button, or pressing Enter).

I’m wondering the same thing for the likes of:

If you were communicating to a server, I think conventional wisdom says to validate at server-side too. So perhaps this is important if you’re validating json to post.[1]

UPDATE (23rd July)

without-validating-an-empty-string

Just to answer my own question, it is indeed worthwhile to double check data on saving to the Model, in the unlikely event that someone screws up your <button disabled> with inspect element. It’s a shame HTML isn’t a bit more rigid in that manner.

How likely that is, I don’t know … but it’s a safe way to protect data entry. To be fair, they could probably just as easily screw up your javascript, too!


  1. You might also want to see “What is the “Elm Way” to validate form fields?”. ↩︎

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.