vue-validate-code

Vue validate code
952
Install
npm install vue-validate-code
Latest Version:0.2.0
Vue:3
License:MIT
Last Updated:Oct 19, 2026
Links: GitHub  ·  npm
Maintainer: ntnyq

vue-validate-code

CI NPM VERSION NPM DOWNLOADS LICENSE

[!WARNING] vue-validate-code generates and validates codes entirely in the browser. The SVG renderer exposes its characters as DOM text, and client-side checks can always be bypassed. Use it only as a visual interaction aid—not as CAPTCHA, authentication, or abuse prevention. Security-sensitive flows require a server-generated challenge with server-side validation.

Install

npm i vue-validate-code
yarn add vue-validate-code
pnpm add vue-validate-code

Usage

<script lang="ts" setup>
import { ref, useTemplateRef } from 'vue'
import { ValidateCode } from 'vue-validate-code'

const validateCode = ref('')
const validateCodeRef = useTemplateRef('validateCodeRef')

function handleTriggerValidate() {
  if (!validateCode.value) {
    return console.log('No validate code value')
  }
  validateCodeRef.value?.validate(validateCode.value)
}
function handleValidateCallback(isValid: boolean) {
  if (isValid) {
    console.log('validate success')
  } else {
    console.log('validate fail')
    validateCodeRef.value?.update()
  }
}
</script>

<template>
  <ValidateCode
    @validate="handleValidateCallback"
    ref="validateCodeRef"
    renderer="svg"
  />
  <input
    v-model="validateCode"
    placeholder="Fill the validate code"
  />
  <button
    @click="handleTriggerValidate"
    type="button"
  >
    Validate
  </button>
</template>

Renderer

ValidateCode supports two built-in renderers:

  • canvas (default)
  • svg
<ValidateCode renderer="canvas" />

<ValidateCode renderer="svg" />

Docs

Check more examples and APIs in Docs

License

MIT License © 2025 to PRESENT ntnyq

Related Packages

@xunlei/vue-lazy-component

Vue.js 2.0 组件级懒加载方案 Vue.js 2.x component level lazy loading solution

14,137 1,003
@xunlei/vue-context-menu

Vue 2.0 右键菜单组件,菜单内容可以随意自定义

7,700 335
vue-timepicker

timepicker, vue-component, vue-plugin

3,528 10
vue-fixed-header

Simple and cross-browser friendly fixed header component for Vue.js.

111,486 167
google-recaptcha-vue3

A lightweight Vue 3 component library supporting Google reCAPTCHA v2 and v3 inte...

3,291 1

Version History

Version Released Vue License
0.2.0 ^3.5.0 MIT
0.1.0 ^3.0.0 MIT
0.0.10 ^3.0.0 MIT
0.0.9 ^3.0.0 MIT
0.0.8 ^3.0.0 MIT