title: In Vue v2, How do I verify if a value entered into a form is empty?
body: <p>I've tried many different ways to do this with both alert() and simple if-else statements, and even what is at this link: <a href="https://v2.vuejs.org/v2/cookbook/form-validation.html" rel="nofollow noreferrer">https://v2.vuejs.org/v2/cookbook/form-validation.html</a></p>
  <p>But nothing works! What am I doing wrong?</p>
  <p>What is in my index.html:</p>
  <pre><code>  &lt;div id=&quot;app&quot;&gt;
      &lt;div class = &quot;addTask&quot;&gt;
      &lt;h1&gt;A List of Tasks&lt;/h1&gt;
      &lt;p v-show=&quot;activeItems.length === 0&quot;&gt;You are done with all your tasks! Celebrate!&lt;/p&gt;
        &lt;form @submit.prevent=&quot;addItem&quot;&gt;
          &lt;input type=&quot;text&quot; v-model=&quot;title&quot;&gt;
          &lt;button type=&quot;submit&quot;&gt;+&lt;/button&gt;
        &lt;/form&gt;
      &lt;/div&gt;
  </code></pre>
  <p>This is what I have in scripts.js:</p>
  <pre><code>var app = new Vue({
    el: '#app',
    data () {
      return {
        // errors: [],
        items: [{
          userId: 0,
          id: 0,
          title: &quot;&quot;,
          completed: false,
          }],
          title: '',
          show: 'all',
      }
    },
    // Using axios to asynchrously query the API
    mounted () {
      axios
        .get(&quot;https://jsonplaceholder.typicode.com/todos&quot;)
        .then(response =&gt; this.items = response.data)
    },
    computed: {
      activeItems() {
        this.saveItems;
        return this.items.filter(item =&gt; {
          return !item.completed;
        });
      },
      filteredItems() {
        // An active state denotes the task is not yet completed
        if (this.show === 'active')
          return this.items.filter(item =&gt; {
            return !item.completed;
          });
        if (this.show === 'completed')
          return this.items.filter(item =&gt; {
            return item.completed;
          });
          //  This makes it so added tasks go to the top, not bottom
        return this.items.reverse();
      },
      
    },
    methods: {
      addItem() {
  
        if(this.items != 0) {
          this.items.push({
            title: this.title,
            completed: false
          })
          this.title = &quot;&quot;;
        }
        else {
          alert(&quot;Please enter a task.&quot;)
        }
  </code></pre>