Let's say we want to add form validation in JavaScript, first we need to stop the form from actually submitting. We can do this very simply in JavaScript. HTML Structure <form onsubmit="return validate();" novalidate> <input type="text" name="name"...

Markdown supported Β· ββ΅ to post
Francisco Quintero
Software Engineer & Ruby on Rails Developer
event.preventDefault()should be use when the submit event is going to be handled somewhere else.You're example is simple but works as expected π