inxcapable Posted May 23, 2014 Share Posted May 23, 2014 We are building a business card for a client. It's pretty straightforward except for the fact that we need to use two different fonts to create the card - one for numbers and one for text. In order to control the fonts we need to use JavaScript rules. The fields that are impacted are the street address and email address fields. Text = MrEavesSanOT Numbers = MrEavesModOT PTI supplied this Javascript rule for us to use: newAddress = '<f name="MrEavesSanOT">' + Field("Address").replace(/(\d+)/g, '<f name="MrEavesModOT">$1</f>'); return newAddress; It sort of works, but it causes a situation where if a house number is followed by a street number, the numbers concatenate. 777 77th Avenue reads as 77777th Avenue. They told us to remove </f> after MrEavesModOT. It corrects the concatenation issue. But then causes any text that appears after a number to render as MrEavesModOT. We need text to be rendered as MrEavesSanOT. I’d appreciate your feedback. Thanks! Quote Link to comment Share on other sites More sharing options...
inxcapable Posted July 1, 2014 Author Share Posted July 1, 2014 Does anyone have insight to this issue? We're still unresolved and I need to launch this site in the next couple of week. Quote Link to comment Share on other sites More sharing options...
step Posted July 1, 2014 Share Posted July 1, 2014 Would this work? newAddress = '<f name="MrEavesSanOT">' + Field("Address").replace(/(\d+)/g, '<f name="MrEavesModOT">$1<f name="MrEavesSanOT">'); return newAddress; Quote Link to comment Share on other sites More sharing options...
dreimer Posted July 1, 2014 Share Posted July 1, 2014 I used this in the past. May work. function replace_helper(match, digits, spaces) { return '<f name="MrEavesModOT">' + digits + '</f>' + Array(spaces.length + 1).join(" "); } return Field("YOURFIELDHERE").replace(/(\d+)(\s*)/g, replace_helper); Using MrEavesSanOT for your variable field in the text box. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.