开发者

I want to truncate address line 2 to 10 characters

I want to truncate address line 2 to 10 chara开发者_如何学Gocters if a value greater than 10 characters is returned in the address validation response for address line 2. we also have address line 1 which is set to max of 40 characters, if address line 1 exceeds 40 characters and the result comes to address line 2,and if the length for address line 2 reaches more than 10 characters then i need to truncate that to 10 characters. hope i made it clear. can any one give an example for that.

Thanks Lucky


Try this:

valueYouWantToTrucante.substr(0,10);

More info on the substr method.

If sounds like you only want to do this if some condition is true; did you also need help writing that condition?


Since @Lucky asked for help w/ the condition. This is psuedo code:

if((address1Text.length > 40) && (address2ValidationResult.length > 10)){
    valueYouWantToTrucante.substr(0,10);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜