TypeError: .substring is not a function

江枫思渺然 提交于 2020-12-12 11:58:08

问题


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 is not a function 3:AcroForm:CC.CardNumber:Annot1:OnBlur:Action1Exception in line 1051 of function AFSimple_Calculate, script byteCodeTool


回答1:


if it is a card number then you need to convert it into a String.

var first = fld.value.toString().substring(0,1);



来源:https://stackoverflow.com/questions/48013280/typeerror-substring-is-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!