Skip to content

Slider Captcha

Puzzle verification with random shapes (square / triangle / trapezoid / pentagon) and decoy holes with random rotation.

Example

javascript
import { SliderCaptcha } from '@captcha-pro/core'

const captcha = new SliderCaptcha({
  el: '#slider-captcha',
  width: 300,
  height: 170,
  precision: 5,
  showRefresh: true,
  onSuccess: () => console.log('Verification passed!'),
  onFail: () => console.log('Verification failed!')
})

const data = captcha.getData()
console.log('Target position:', data.target)

Options

OptionTypeDefaultDescription
elstring | HTMLElement-Container element or selector
bgImagestring-Background image URL
sliderImagestring-Slider image URL
widthnumber300Container width
heightnumber170Container height
sliderWidthnumber42Slider piece width
sliderHeightnumber42Slider piece height
precisionnumber5Verification precision (px)
showRefreshbooleantrueShow refresh button
classNamestring'captcha-slider'Custom class name
verifyMode'frontend' | 'backend''frontend'Verification mode
backendVerifyBackendVerifyOptions-Backend verification config
securitySecurityOptions-Security options
onSuccess() => void-Success callback
onFail() => void-Fail callback
onRefresh() => void-Refresh callback

See API Options for BackendVerifyOptions and SecurityOptions.

Instance Methods

MethodDescription
verify(data)Manually verify captcha
reset()Reset captcha state
refresh()Generate new captcha
destroy()Destroy captcha instance
getData()Get captcha data
getSignedData()Get signed data for backend verification
getStatistics()Get verification statistics
resetStatistics()Reset statistics

Released under the MIT License.