类型错误:.substring 不是函数 [英] TypeError: .substring is not a function
问题描述
我正在运行 Acrobat Pro DC.我有一个带有 Action/OnBlur 事件的文本字段(CC.CardNumber"),该事件运行产生此错误的以下脚本.我已经研究了几个小时,但看不出我的代码哪里不正确.
I'm running Acrobat Pro DC. I have a text field ("CC.CardNumber") with an Action/OnBlur event that runs the following script that produces this error. I've researched this for hours and can't see where my code is incorrect.
var fld = this.getField("CC.CardNumber");
var first = fld.value.substring(0,1);
fld.value = first;
TypeError: fld.value.substring 不是函数3:AcroForm:CC.CardNumber:Annot1:OnBlur:Action1Exception in line 1051 of function AFSimple_Calculate, script byteCodeTool
TypeError: fld.value.substring is not a function 3:AcroForm:CC.CardNumber:Annot1:OnBlur:Action1Exception in line 1051 of function AFSimple_Calculate, script byteCodeTool
推荐答案
如果是卡号,则需要将其转换为字符串.
if it is a card number then you need to convert it into a String.
var first = fld.value.toString().substring(0,1);
var first = fld.value.toString().substring(0,1);
这篇关于类型错误:.substring 不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!