Also each browser has a slightly different default behaviour.
The simplest change you can make to your forms is to mark a text input field as 'required': This informs the (HTML5-aware) web browser that the field is to be considered mandatory.
I think checking for Input is enough to accommodate browsers which provide for HTMLInput ELements, but I don't think there's any nice way to test this without selenium or something. Maybe I'm wrong, but it would be good to get people considering whether sanitizing an invalid string by simply returning an empty string is the "right thing to do".
I certainly don't see any mention of doing this in the specs anywhere, unless I'm missing something.
Fixes #2144 On Chromium / Safari / Opera, currently: When a non-numeric string is entered into an input[type=number], the browser reports the value and inner Text as the empty string.