Reputation: 1898
How to display the text as hyperlink if the user entered in the text box...
For example if the user entered the text as
"my website name is google.com"...and submit it,
i have to show that text as "my website name is google.com"
Is there any plugin available for this or any simple script is enough?
Upvotes: 1
Views: 405
Reputation: 13278
This is usually called "linkify" which I guess is a bit difficult to Google for if you don't know that.
Here is a jQuery plugin that will do this for you.
Upvotes: 1
Reputation: 5176
function replaceURLWithHTMLLinks(text) {
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
return text.replace(exp,"<a href='$1'>$1</a>");
}
Thanks to: How to replace plain URLs with links?
Upvotes: 2