简体   繁体   English

Acrobat DC:带日期选择器的未格式化文本字段?

[英]Acrobat DC: Unformatted text field with date picker?

In short: I want to use Acrobat DC's built-in date picker on a text field without using Acrobat's Format option. 简而言之:我想在文本字段上使用Acrobat DC的内置日期选择器,而不使用Acrobat的“格式”选项。

In full: 在全:
I'm trying to enable the date fields in my form to accept a large variety of date formats as input, including a date picker. 我正在尝试使表单中的日期字段能够接受多种日期格式作为输入,包括日期选择器。 I've written validation code to accomplish this, however Acrobat is rejecting inputs before the validation code triggers and rewrites the date into an acceptable format. 我已经编写了验证代码来完成此操作,但是Acrobat会在验证代码触发并将日期重写为可接受的格式之前拒绝输入。 This means that I have to set the field's format to "None" in order for my validation code to fire properly, losing the built-in date picker in the process. 这意味着我必须将字段的格式设置为“无”,以使我的验证代码正确启动,从而在此过程中丢失内置的日期选择器。 While this doesn't make the form not work, it hampers UX, which is something I've been working to strongly improve in this form. 尽管这不能使表单无法正常工作,但会阻碍UX,这是我一直在努力改进的一种形式。

To illustrate the issues: 为了说明问题:
Ideal/Goal: 理想/目标:

  • Input "May 25, 2017" into Date Field 在“日期”字段中输入“ 2017年5月25日”
  • Validation code converts this to "2017 05 25" 验证码将其转换为“ 2017 05 25”
  • Acrobat formatting applies (expects: "yyyy mm dd"), enabling the date picker 应用Acrobat格式(期望:“ yyyy mm dd”),从而启用日期选择器
  • Acrobat Date Picker is available for more rapid input changes Acrobat Date Picker可用于更快速的输入更改

Current Problem: 当前问题:

  • Input "May 25, 2017" into Date Field 在“日期”字段中输入“ 2017年5月25日”
  • Acrobat formatting applies (expects: "yyyy mm dd"), rejects inputs 应用Acrobat格式(期望:“ yyyy mm dd”),拒绝输入
  • Validation code has nothing to work with 验证码与之无关
  • Acrobat Date Picker is available for more rapid input changes Acrobat Date Picker可用于更快速的输入更改

Current non-ideal solution: 当前的非理想解决方案:

  • Input "May 25, 2017" into Date Field 在“日期”字段中输入“ 2017年5月25日”
  • Validation code converts this to "2017 05 25" 验证码将其转换为“ 2017 05 25”
  • Acrobat formatting disabled Acrobat格式已禁用
  • No Acrobat Date Picker 没有Acrobat日期选择器

I see three possible solutions, but don't know enough on how to (or if I can) achieve them. 我看到了三种可能的解决方案,但是对如何(或者如果我能做到)了解不够。

  1. Preempt Adobe's built in formatting script somehow. 以某种方式抢占Adobe的内置格式化脚本。 I've tried calling event.change and event.willCommit, but I clearly don't understand them enough to use them properly. 我曾尝试调用event.change和event.willCommit,但我显然对它们的理解不足以正确使用它们。 Additionally, I thought script precedence was Keystroke > Validation > Format > Calculation, but it appears either I'm wrong or Adobe's built in formats are special. 此外,我认为脚本优先顺序是“击键”>“验证”>“格式”>“计算”,但是似乎我错了或者Adobe的内置格式很特殊。
  2. Force enable the date picker somehow. 以某种方式强制启用日期选择器。 I don't have high hopes for this. 我对此没有很高的期望。 I don't get why Adobe didn't make the damn thing a check box option. 我不明白为什么Adobe不会把该死的东西变成复选框选项。
  3. Set the Format option to a wildcard somehow. 以某种方式将“格式”选项设置为通配符。 Like the last three, I don't know if this is possible, but this seems the most likely to work. 像后三个一样,我不知道这是否可行,但这似乎最有可能起作用。 Basically, let the format accept anything. 基本上,让格式接受任何内容。

You'll need to use two fields. 您需要使用两个字段。 The first one is the main field and uses a custom format script to format your date, not one of the predefined ones. 第一个是主字段,它使用自定义格式脚本来格式化日期,而不是预定义的日期。 Right beside it is a field formatted for a date that's just wide enough to give you the picker, set it's text color to white so that none of the characters in the value actually show. 在它的旁边是一个字段,该字段的日期格式刚好足以为您提供选择器,将其文本颜色设置为白色,以便该值中的任何字符都不会实际显示。 Use the OnBlur action to update the first field when the user exits the second. 用户退出第二个字段时,请使用OnBlur操作更新第一个字段。 If you put them right up against each other, to the end user, they'll appear to be the same field. 如果您将它们彼此对立,那么对于最终用户,它们将显示为同一字段。

In addition to @joelgeraci 's answer, you might also consider a non-Adobe date picker (which requires the very newest versions of Acrobat/Reader anyways). 除了@joelgeraci的答案外,您还可以考虑使用非Adobe日期选择器(无论如何,它仍然需要最新版本的Acrobat / Reader)。 There are a few out there, some better some a bit less… 那里有些,有些更好一些…

Shameless plug: yours truly happens to have created the most elaborate and configurable date picker for PDF forms; 无耻的插件:您的确碰巧为PDF表单创建了最详尽和可配置的日期选择器; for more information and quotes, feel free to contact me in private. 有关更多信息和报价,请随时与我私下联系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM