Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6769629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:12:57+00:00 2026-05-26T15:12:57+00:00

So I have this function here: function ShowMessage() { var themessege = document.getElementById(Form).textarea1.value; var

  • 0

So I have this function here:

function ShowMessage()
{
   var themessege = document.getElementById("Form").textarea1.value;
   var dat = new Date(); 
   var fileName = document.getElementById("theFile").value;
   var image = '<img src="' + fileName + '"/>' + '<br>';
   document.getElementById("Form").textarea1.value = ""; 
   document.getElementById("Form").countdown.value = "160"; 
   document.getElementById("theFile").value = "";
   if (themessege==null || themessege=="") 
       {
       alert("There is no text to submit, please fill out the text box");
       return false;
       }

   document.getElementById("blog").innerHTML = document.getElementById("blog").innerHTML + image +  "Guest post: " + themessege + "<br />" +  dat +"<br />";   
}

I can get the text from the text area, as well as the image the user uploads. I’m wondering how I can divide the strings in the text area into subsrtings to check if they start with “www” or “htt”.

This is what I’ve written so far:

function linkify(inputText) {
   var replaceText, replacePattern1, replacePattern2;

   //URLs starting with http://, https://
   replacePattern1 =https;
   replacedText = inputText.replace(replacePattern1, '<a href= ></a>');

   //URLs starting with "www." (without // before it, or it'd re-link the ones done above).
   replacePattern2 = www.;
   replacedText = replacedText.replace(replacePattern2, <a href="http:  ></a>');
   var x = getelementbyid("blog");
   for(var i = 0;i < x.length;i++){
      if(blog.charAt(i) == replacePattern1){
      return replacedText;
      }
   }
   else if(blog.charAt(i) == replacePattern2){
     return replacedText;
   }
}

I know that the charAt(i) only checks for 1 letter….

Most of the answers that I found were on PHP, I’m trying to find a solution using JavaScript.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:12:58+00:00Added an answer on May 26, 2026 at 3:12 pm

    linkify function is not correctly written. try this one.

    function linkify(inputText) {
    var regUrl = /(http:[\d]{0,4}\/\/)?[a-zA-Z0-9\-\.]+\.(com|org|net|mil|edu|COM|ORG|NET|MIL|EDU)/;
    
    return inputText.replace(regUrl,'<a href="" />');
    }
    ;
    alert(linkify('string containing link www.google.com'));// output: string containing link <a href="" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this function (sample here: http://jsbin.com/emabe4/ ) var a=[]; var log = document.getElementById('log');
I have this function: $(document).ready(function(){ function Fos(buttonSel, inputSel, someValue, cssProperty) { $(buttonSel).click(function(){ var value
I have this simple function: <script type=text/javascript> //<![CDATA[ jQuery(function($){ function here(b){alert(b);} ; here(6); });
Code is not running on .click when I have this: $(.cancel).click(function() { alert(got here);
Here is the situation. I have some javascript that looks like this: function onSubmit()
Here's the story... I have a jQuery function that does something, this function is
I have this function in my head: <head> window.onload = function(){ var x =
I have this function... private string dateConvert(string datDate) { System.Globalization.CultureInfo cultEnGb = new System.Globalization.CultureInfo(en-GB);
I have this tail recursive function here: def recursive_function(n, sum): if n < 1:
I have this SphereInFrustrum function here: 0.49% int FrustumG::sphereInFrustum(Vec3 &p, float radius) { int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.