【问题标题】:adobe acrobat XI pro javascriptadobe acrobat XI pro javascript
【发布时间】:2012-10-17 04:21:41
【问题描述】:

当我不在表单域上时,我正在调用一个 javascript 函数。所以我要做的是,如果我勾选了必填字段作为必填字段,它将有一个红色边框,我可以编写一个脚本来在字段中有值时删除必填选项吗?

var thisValue = this.getField("companyName").value;
var regexLetter = /[A-Z]+$/;
var Icon = "0"; //0 — Error (default) // 1 — Warning // 2 — Question // 3 — Status
var Type = "0"; //0 — OK (default) // 1 — OK, Cancel // 2 — Yes, No // 3 — Yes, No, Cancel
if (thisValue == ""){
    app.alert({
            cMsg:"this is an warning",
            cTitle: "thsi is title",
            nIcon: Icon, 
            nType: Type
        })

} else if(!regexLetter.test(thisValue)){
  app.alert('Type alphanumeric character');
}

【问题讨论】:

    标签: adobe acrobat


    【解决方案1】:

    这会很晚,但这是我在文档中的做法:

    var _companyName = this.getField("CompanyName");
    
        _companyName.required = (_companyName.value === "");
    

    你也可以强加其他依赖,比如:

    var _companyName = this.getField("CompanyName"),
        _companyLicense = this.getField("CompanyLicense");
    
        _companyLicense = ((_companyLicense === "")
            && (_companyName !== ""));
    

    将脚本拆分为几个文件可能会有所帮助。我使用包含绝大多数逻辑的“共享”脚本和“特定”脚本来遍历每个单独的文档。此外,请确保在添加脚本时仅以正确的顺序将它们命名为 1、2、3 等,否则 Acrobat 将变得愚蠢。希望对您有所帮助。

    【讨论】:

      猜你喜欢
      • 2014-08-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多