# 在账户创建表单中提交隐藏字段

**URL:** https://meta.discourse.org/t/submitting-hidden-fields-in-account-creation-form/142169
**Category:** Development
**Created:** [2020年二月20日 19:04 UTC](https://meta.discourse.org/t/submitting-hidden-fields-in-account-creation-form/142169 "2020-02-20T19:04:28Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![agmontpetit](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/agmontpetit/32/160109_2.png) [@agmontpetit](https://meta.discourse.org/u/agmontpetit)
#### Post date: [2020年二月20日 19:04 UTC](https://meta.discourse.org/t/submitting-hidden-fields-in-account-creation-form/142169/1 "2020-02-20T19:04:28Z")

</div>

我尝试在用户创建账户时添加 [UTM 参数](https://en.wikipedia.org/wiki/UTM_parameters) 作为用户自定义字段。我的计划如下：

- 在 Discourse 管理设置中添加用户自定义字段
- 从 URL 解析 UTM 参数并将其存储在 cookie 中，以便随时访问
- 在账户创建表单中设置隐藏输入值
- 使用 jQuery 将这些隐藏字段的值填充为对应的值

然而，表单中的字段似乎存在一个问题，这似乎是因为需要点击它们——就像密码字段需要点击以触发验证并最终允许提交表单一样。

有人知道如何用 jQuery 绕过这个问题吗？

 ![Screen Shot 2020-02-20 at 20.02.02.png](https://global.discourse-cdn.com/meta/original/3X/0/f/0f9531840cd4ef230664aa9097dfbe6c12046d92.png)

 ![Screen Shot 2020-02-20 at 20.02.34.png](https://global.discourse-cdn.com/meta/original/3X/9/8/985970c42246d8151965e16788c0eb19476cd558.png)

---

<div class="post-metadata">

### Author: ![agmontpetit](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/agmontpetit/32/160109_2.png) [@agmontpetit](https://meta.discourse.org/u/agmontpetit)
#### Post date: [2020年二月26日 14:32 UTC](https://meta.discourse.org/t/submitting-hidden-fields-in-account-creation-form/142169/2 "2020-02-26T14:32:24Z")

</div>

如果这能帮到某人，我漏掉了触发一个事件。例如：  
`$('.user-field.user-field-utm_source input').trigger('change');`
