You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Survey.js标题HTML失效及KVKK、Captcha功能需求咨询

Survey.js表单配置:KVKK勾选框、标题HTML、Captcha验证解决方案

1. 标题HTML不生效的解决办法

Survey.js默认会转义标题中的HTML代码,要让HTML渲染生效,有两种方式:

  • 全局开启:在Survey模型配置里添加allowHtmlInTitle: true,这样所有标题都支持HTML
  • 单页开启:针对特定页面的标题,设置html: true

示例代码:

// 全局开启的写法
const survey = new Survey.Model({
  allowHtmlInTitle: true,
  title: "<h3>表单主标题</h3><p>这里插入KVKK相关的说明文本</p>",
  pages: [/* 页面配置 */]
});

// 单页开启的写法
pages: [
  {
    title: "<p>页面标题:包含KVKK说明</p>",
    html: true,
    questions: [/* 问题配置 */]
  }
]

2. 添加KVKK必填勾选框

直接新增一个复选框问题,设置为必填项,内容填写KVKK同意声明:

questions: [
  {
    type: "checkbox",
    name: "kvkk_consent",
    title: "我已阅读并同意KVKK隐私政策的全部条款",
    isRequired: true,
    choices: [{ value: "agree", text: "同意" }]
  }
]

用户必须勾选此选项才能提交表单。

3. 接入Captcha验证

Survey.js支持集成Google reCAPTCHA,步骤如下:

  1. 前往Google reCAPTCHA平台申请site密钥和密钥
  2. 在表单中添加captcha类型问题,配置site密钥:
questions: [
  {
    type: "captcha",
    name: "form_captcha",
    siteKey: "你的Site密钥",
    theme: "light", // 可选主题:light/dark
    isRequired: true
  }
]

如果需要自定义Captcha实现,也可以通过Survey.js的自定义Widget功能进行扩展。

内容的提问来源于stack exchange,提问作者Erdal Güler

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 04:16:00