Make email field a link
Posted: 08 Aug 2017
I have a form field that contains an email address. Is there a way to make this a mailto link based on the email address, which will open in the users default mail app?
Design SharePoint forms with tabs, complex tables, accordions, sub-lists, and 3rd party columns
https://spform.com/forum/
Code: Select all
<a href="mailto:email@mail.com">email@mail.com</a>
Good day Nikita,Nikita Kurguzov wrote: ↑09 Aug 2017Hello, Jaydius!
It should happen on its own, you don't need to do anything special. If your text field contains a valid email address, when you open it in Read Only mode, it would automatically generate something like this:You can check it in the browser's inspector. If this doesn't happen, let us know and post a screenshot, please.Code: Select all
<a href="mailto:email@mail.com">email@mail.com</a>
Correct, it's only displaying in plain text.Nikita Kurguzov wrote: ↑10 Aug 2017Yes, in case you are using Lookups instead of standard text field, it wouldn't generate this link automatically. Instead, it should generate links to the item itself. Are you saying it's only displaying lookup field as plain text? We need to know it in order to write appropriate code for your case.
Code: Select all
var myVar = setInterval(myTimer, 100);
function myTimer() {
var email = fd.field('FieldName').value();
if (email)
{
var string = "<a href=mailto:" + email + ">" + email + "</a>";
fd.field('FieldName').control()._el().html(string);
clearInterval(myVar);
}
}
Works perfectly. Thank you very much for your help Nikita.Nikita Kurguzov wrote: ↑11 Aug 2017Try using this code in JavaScript editor:Sadly, we can't avoid using the Timer here. Replace FieldName with the internal name of the Email field.Code: Select all
var myVar = setInterval(myTimer, 100); function myTimer() { var email = fd.field('FieldName').value(); if (email) { var string = "<a href=mailto:" + email + ">" + email + "</a>"; fd.field('FieldName').control()._el().html(string); clearInterval(myVar); } }