Just one comment about adding links on Enter. I've seen many people forget, especially in JS land, that there is a form element. You can add the function call as the submit handler and you have Enter by default.
UI/UX Developer working within a range from emails, design and development. Dabbles with Wordpress. Working on React and related technologies at the moment.
Great point! I was working so hard on other examples that I'd seen and forgot I could use a form.
Is my example practical for a form or does it not matter? If this was a live project would I have to worry about sanitation and other things with submitting?
Forms are a logical grouping of inputs. Yours is pretty practical use as it reduces manually event listening. For the modern JS frameworks, creating SPAs, they make less sense as you're mostly making AJAX requests anyway.
For non-SPA Applications, they're very useful as you can add action and method attributes and the default submitting behavior then sends it to the server.
For live projects, HTML5 has native validations for inputs, the-art-of-web.com/html/html5-form..., though I can't recall at the moment if they require the form tag.
Sanitation would need to be done manually though.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is great!
Just one comment about adding links on Enter. I've seen many people forget, especially in JS land, that there is a form element. You can add the function call as the submit handler and you have Enter by default.
codepen.io/maccabee/pen/yvWoLd
Great point! I was working so hard on other examples that I'd seen and forgot I could use a form.
Is my example practical for a form or does it not matter? If this was a live project would I have to worry about sanitation and other things with submitting?
Forms are a logical grouping of inputs. Yours is pretty practical use as it reduces manually event listening. For the modern JS frameworks, creating SPAs, they make less sense as you're mostly making AJAX requests anyway.
For non-SPA Applications, they're very useful as you can add action and method attributes and the default submitting behavior then sends it to the server.
For live projects, HTML5 has native validations for inputs, the-art-of-web.com/html/html5-form..., though I can't recall at the moment if they require the form tag.
Sanitation would need to be done manually though.