Prevent default in Vue.js after checking value
470
post-template-default,single,single-post,postid-470,single-format-standard,bridge-core-3.0.1,qodef-qi--no-touch,qi-addons-for-elementor-1.5.3,qode-page-transition-enabled,ajax_updown,page_not_loaded,,vertical_menu_enabled,side_area_uncovered_from_content,qode-theme-ver-28.7,qode-theme-bridge,disabled_footer_top,qode_header_in_grid,wpb-js-composer js-comp-ver-6.8.0,vc_responsive,elementor-default,elementor-kit-6

Prevent default in Vue.js after checking value

Prevent default in Vue.js after checking value

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;
        }
 },


Mastodon