Issue with Vue-Validator form validation not functioning properly on JS Fiddle

I'm having trouble with vue-validator on JSFiddle. Can someone please assist in troubleshooting the issue so I can proceed with my main question? Check out JSFiddle

Html:

    <div id="app">
      <validator name="instanceForm">
        <form v-on:submit.prevent="addInstance()">
          <div class="form-group">
            <input id="'instancetext" type="text" class="form-control" placeholder="Enter new Instance" v-validate:instancetext="{ required: { rule: true, message: 'What is the instance ?'}}" v-model="todo.name">
            <div class="errors" v-if="showErrors">
              <span v-if="$instanceForm.instancetext.required">{{$instanceForm.instancetext.required}}</span>

            </div>
          </div>

          <div class="form-group">
            <button class="btn btn-default"> <i class="fa fa-plus"> </i> Add
            </button>
          </div>
        </form>
      </validator>

      <div class="">
        <div v-for="todo in todoStore" class="list-group">


          <div class="list-group-item">
            <h4>
                        Main Card
                    </h4> {{todo.name}} {{todo.id}}
          </div>
          <div class="list-group-item nopadding">

            <button class="btn btn-xs btn-danger margin-10" v-on:click="todoDelete(todo)">
              <i class=" fa fa-trash"></i>
            </button>
            <form @submit="addNoteInstance">


              <div class="form-group">
                <input id="note-@{{note.id}}" type="text" class="form-control" name="note-@{{note.id}}" placeholder="Enter new Note Instance" v-model="name">

                <button type="submit"><i class="fa fa-plus"> Add Note Instance</i></button>
              </div>
            </form>
          </div>

          <div v-for="note in todoNoteStore" class="list-group nopadding nomargin">
            <div v-if="todo.id == note.id">




              <div class="list-group-item">
                <h4>
                                Note fore card {{todo.id}}
                            </h4> {{note.id}}{{note.name}}
              </div>
              <div class="list-group-item  nopadding">

                <button class="btn btn-xs btn-danger margin-10" v-on:click="removeNoteInstance(note)">
                  <i class=" fa fa-trash"></i>
                </button>

              </div>

            </div>
          </div>
        </div>
      </div>

      <pre>{{ $data | json }}</pre>
    </div>

Js:

     new Vue({
       el: '#app',
       data: function() {
         return {
           showErrors: false,
           todo: {
             id: 1,
             name: '',
             completed: false,
             check: ''
           },
           todoNote: {
             id: 1,
             name: '',
             completed: false,
             check: ''
           },

           todoStore: [


           ],

           todoNoteStore: [

           ]

         }
       },
       methods: {

         addInstance: function() {

           if (this.$instanceForm.valid) {
             this.todoStore.push(this.todo);
             this.todo = {};
             this.showErrors = false;


           } else {
             this.showErrors = true;

           }

         },

         addNoteInstance: function(e) {
           e.preventDefault();
           this.todoNoteStore.push({
             "id": 1,
             "name": this.name,
             "completed": false,
             "check": ''
           });

           this.name = '';
         },

         removeNoteInstance: function(note) {
           this.todoNoteStore.remove(note);
         }

       }
     });

css:

.nopadding {
  padding-top: 0px;
  !important;
  padding-bottom: 0px;
  !important;
}

.nomargin {
  margin: 0px;
}

Answer №1

Here lies a dual dilemma.

  1. The trouble arises from your choice of CDN for Vue-Validator (v2.1.7) as it appears to be malfunctioning. The links for version 2.1.6 and 3.0.0-alpha1 seem to function properly. (specifically concerning links on cdnjs)

  2. Note that Vue-Validator 2.x is specifically designed for use with Vue 1.x, whereas the CDN you are utilizing for Vue directs to version 2.0.3.

Hence, the solution is to either opt for Vue 1.x along with a functional Vue-Validator 2.x, or go for Vue 2.x coupled with Vue-Validator 3.x (which is currently in its alpha phase).

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Transferring information between Rails views and Vue.js

Having some trouble passing an instance variable from my Rails view to a Vue.js component. The error message displaying is: Property or method "epic_list" is not defined on the instance but referenced during render. Let's take a look at the code: V ...

Object displaying no visible illumination

Recently, I've been experimenting with this project, and after some trial and error, I've managed to get things working to some extent. As a novice in JavaScript, I'm unsure if the issue I'm facing has a simple solution. The problem is ...

Having issues with JavaScript and MySQL data retrieval following XMLHttp update to the database

After running the newNet.php file successfully creates a new entry and assigns it an auto-incremented netID. The next step is to retrieve this newly created ID and use it in the showActivities() function to display the record. Ideally, it should work like ...

Assign the "this" keyword of App.vue to the Vuex state

I have discovered a workaround for accessing vue-router and other services that only works within a Vue component. By saving the "this" of the Vue app in the state of Vuex within the created option of App.vue. Is this a good approach or could it potential ...

Randomly selecting an element from an array as the default option in vue.js

I am working on a neat little tool to learn vue.js where users can find out the time it takes to travel from one location to another: Codepen It's functioning fairly well at the moment, but I want to include a random value from each array when the pa ...

When a URL is triggered via a browser notification in Angular 2, the target component ceases to function properly

Whenever I access a URL by clicking on a browser notification, the functionality of the page seems to stop working. To demonstrate this issue, I have a small project available here: https://github.com/bdwbdv/quickstart Expected behavior: after starting t ...

Refresh the Rails HTML table with new data by incorporating ajax requests and vanilla JavaScript

I'm struggling to find a solution without using jQuery in my current scenario. How can I refresh a partial on my page without reloading the entire page? Within my new.html.erb file, there's a button that triggers a JavaScript function each time ...

The functionality to redirect in Wordpress Contact Form 7 based on the value of a radio button selection does

For the past 5 hours, I have been diving deep into Contact Form 7 redirects that are based on values. Despite my efforts, I am unable to figure out why my code isn't functioning properly. Is there anyone who can spot the issue? Contact Form Radio But ...

Creating a string specifically for implementing regular expressions in JavaScript

I'm currently working on a custom jQuery plugin known as jQuery-Faker. This plugin is designed to produce fake data for populating form fields based on their respective field names. One of the tasks I have set out to accomplish is generating phone num ...

Ways to access the files attribute in an input tag in AngularJS without relying on getElementById

I am currently working on file uploads using AngularJS and I have a question regarding how to retrieve input files similar to regular JS. What I want to achieve: HTML: <input type="file" name="file" id="fileImg" accept="image/*"> JS: var file ...

Developing secure web applications using Node.js and Express with HTTPS encryption

I am attempting to utilize express with node.js using https. Below is the relevant code for this segment: var express = require("express"); var app = express(); var https = require('https'); var privateKey = fs.readFileSync('./sslcert/myke ...

Oops! We encountered an issue: Unhandled promise rejection. The function n.swapComponent is not defined

Currently, I am in the process of developing an application with Laravel using Jetsream and the Vuejs & Inertia stack. After executing the npm audit fix command, my entire application is displaying a blank page. The reason behind running the npm command n ...

Searching for an individual MongoDB document using Express

I recently started working with MongoDB and express. I am trying to authenticate a user based on their username and password, but my code seems to always execute the "else statement" even when the correct credentials are entered. Below is the JavaScript f ...

Setting references to child components with VueRouter in Vue

I've written the following code snippet in my main.js file for my Vue web application: const routes = { name: "Main", path: "/main", redirect: "/main/home", component: MainComponent, children: [ { path: &quo ...

Sending a single data point via Ajax on the client side

I am facing an issue with connecting frontend and backend systems. I want to send a single value (radio1Value) from a JavaScript function using jQuery AJAX upon clicking. Is the function structured correctly as I have written it? If yes, how should the R ...

Creating a blurred background effect when a React portal is presented

I have implemented React portals to display a modal popup after the form is submitted. However, I am facing an issue with blurring only the background while showing the modal, similar to what is shown in picture 2. Initially, I tried using document.body.st ...

If variable is greater than, hide the division element

I have a variable called lineNum that increases each time I click on an h1 element I'm attempting to use an 'if' statement to hide a div by setting its display to none, but for some reason, I can't seem to get the 'if' code r ...

getting specific article by id -- vue routing, vuex

Trying to retrieve the article ID and navigate to the detail page for that specific ID. Attempted the following code snippet but encountered an error in the console: api/v1/article[object%20Object]:1 Failed to load resource: the server responded with ...

Retrieving an Enum member based on its value in TypeScript

I am working with an enum called ABC: enum ABC { A = 'a', B = 'b', C = 'c', } In addition, I have a method named doSomething: doSomething(enum: ABC) { switch(enum) { case A : console.log(A); break; case ...

The final value of try_files in nginx fails to function properly in cases where the root directory is variable

In my Vue project, I have implemented a "try_files" configuration to prevent 404 errors when refreshing a URL that is not the root. The code looks like this: location / { ...... root /web/pcResource; try_files $uri $uri/ /index.html; } Everyt ...