Prevent default in Vue.js after checking value

by Thomas Beutel

Here is what I did to prevent a form submit based on a value. In this case, I’m checking to make sure a value is not blank.

 <form id="myform" method="post" v-on:submit="onSubmit" action="/path/to/form-handler">
 methods: {
        onSubmit: function(e) {
            if(this.some_value == ''){
                e.preventDefault();
                return false;
            }
           return true;
        }
 },