hkenney Posted February 12, 2016 Share Posted February 12, 2016 (edited) I'm having trouble writing a rule to change the color of the "@" symbol to black while keeping the rest of the email address red. When I validate the rule it returns my field correctly but it is not changing the color when I preview it. I have checked and I labeled the color exactly how it is spelt in my loaded colors and I have "treat returned strings as tagged text" selected. What am I missing? Thanks! return Field("Email").replace(/@/g, '<color name="Black">@</color>'); Edited February 12, 2016 by hkenney Quote Link to comment Share on other sites More sharing options...
David Miller Posted February 12, 2016 Share Posted February 12, 2016 (edited) I'm having trouble writing a rule to change the color of the "@" symbol to black while keeping the rest of the email address red. When I validate the rule it returns my field correctly but it is not changing the color when I preview it. I have checked and I labeled the color exactly how it is spelt in my loaded colors and I have "treat returned strings as tagged text" selected. What am I missing? Thanks! return Field("Email").replace(/@/g, '<color name="Black">@</color>'); Hmmm. Your rule works for me. Are you sure you are inserting the rule into your text frame and not the Field Email? You could also try escaping the ampersand, but I don't think it is necessary. This works for me as well. return Field("Email").replace(/[color="Red"]\[/color]@/gi, '<color name="black">@</color>'); Edited February 12, 2016 by David Miller Quote Link to comment Share on other sites More sharing options...
hkenney Posted February 12, 2016 Author Share Posted February 12, 2016 Thanks for looking into this David! Yes I am inserting the rule into the text field. I have been trying and trying and nothing is working. Could it be because the red color in the rest of the string is a spot color? I can't see why that would matter but I'm trying to think of anything! Thanks, Hilary Quote Link to comment Share on other sites More sharing options...
David Miller Posted February 12, 2016 Share Posted February 12, 2016 Could it be because the red color in the rest of the string is a spot color? I can't see why that would matter but I'm trying to think of anything! It is working for me regardless of spot or process. Maybe you could collect and upload your template? Quote Link to comment Share on other sites More sharing options...
step Posted February 12, 2016 Share Posted February 12, 2016 Hmmm. Your rule works for me. Are you sure you are inserting the rule into your text frame and not the Field Email? Hilary, I think what David is saying here is that maybe you're inserting your "Email" field into your text frame as opposed to the rule you used to manipulate your "Email" field. You can change your rule to something like this to make sure your template is pulling in the correct rule: return "Yep, I'm the Email rule!"; I agree that your rule looks like it should work. We'd probably have to see your actual template to get a better idea of what's happening. That being said, another thing you could try is using span tags rather than color tags: return Field("Email").replace('@','<span color="Black">@</span>'); Quote Link to comment Share on other sites More sharing options...
hkenney Posted February 12, 2016 Author Share Posted February 12, 2016 Yes, I am using the rule not the email field in the text box. I tried collecting and uploading and that didn't work. Also, I tried using span tags and it is still not working. I am attaching my collect files. Thanks so much guys!Collect2.zip Quote Link to comment Share on other sites More sharing options...
step Posted February 12, 2016 Share Posted February 12, 2016 Okay well now I understand. The rule in your template is not the same as the rule that you posted to the forum. The rule in your template is missing the "name" property for the "color" tag and it's looking for the HTML entity of the '@' symbol rather than the '@' symbol itself: return Field("Email").replace(/[color="red"]& # 6 4 ;[/color]/g, '[color="Red"]<color ="Black">& # 6 4 ;[/color]</color>'); Since your data isn't passing the "@" as the HTML entity, there's no reason to search for it in that field. So ironically, if I change your rule to match the code in your original post (after the forum converted the entity to the @ symbol), I get the desired result: return Field("Email").replace(/@/g, '<color name="Black">@</color>'); Quote Link to comment Share on other sites More sharing options...
hkenney Posted February 12, 2016 Author Share Posted February 12, 2016 IT WORKED!! Sorry I've been trying so many variations I must have lost the name property somewhere along the way. Thank you so much!! 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.