All Components

Validator Overview

The Validator supports the validation of values and other types of user input.

The Validator wrapper for Vue is a client-side wrapper for the Kendo UI Validator widget.

Basic Usage

The following example demonstrates how to initialize the Validator.

<div id="vueapp" class="vue-app">
    <form id="ticketsForm" ref="myForm" v-kendo-validator @submit.prevent="onSubmit">
        <input type="search"
            id="search"
            name="search"
            required
            validationMessage="Field is required"
            class="k-textbox" />

        <div>
            <button class="k-button k-primary" type="submit">Submit</button>
        </div>
    </form>

    <div class="status"></div>
</div>
<style>
    .k-button, .status {
        margin-top: 10px;
    }
    .invalid {
        color: red;
    }
    .valid {
        color: green;
    }
</style>
Vue.use(ValidatorInstaller);

new Vue({
    el: '#vueapp',
    methods: {
        onSubmit: function (ev) {
            var validator = this.kendoValidator
            var status = kendo.jQuery('.status')
            if (validator.validate()) {
                status.text('Hooray! Your data is submitted!')
                  .removeClass('invalid')
                  .addClass('valid')
            } else {
                status.text('Oops! There is invalid data in the form.')
                  .removeClass('valid')
                  .addClass('invalid')
            }
        }
    }
})

Installation

To initialize the Validator, either:

Initializing with Webpack

  1. Install Kendo UI and add a theme.

    npm install --save @progress/kendo-ui
    npm install --save @progress/kendo-theme-default
  2. Install the Kendo UI Validator package for Vue.

    npm install --save @progress/kendo-validator-vue-wrapper
  3. Import the Kendo UI packages to the App component. If you use the Kendo UI components more than once in your application, add all Kendo UI-related files to the main.js file. If you use the Kendo UI components once in your application, add the Kendo UI-related files the component where they will be referred.

    import '@progress/kendo-ui'
    import '@progress/kendo-theme-default/dist/all.css'
    
    import { Validator } from '@progress/kendo-validator-vue-wrapper'
    import { ValidatorInstaller } from '@progress/kendo-validator-vue-wrapper'
    
    Vue.use(ValidatorInstaller)
    
    new Vue({
        el: '#vueapp',
        components: {
            Validator
        }
    })

Functionality and Features

The Validator supports custom validation.

In this article