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 6072635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:10:55+00:00 2026-05-23T10:10:55+00:00

i got a jQuery function to check a textarea for valid urls while someone

  • 0

i got a jQuery function to check a textarea for “valid” urls while someone is typing.

$(".url2").keyup(validNum).blur(validNum);

function validNum() {

var initVal = $(this).val();
outputVal = initVal.replace(/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])$/,"replace this link by bla..");   
if (initVal != outputVal) {
    $(this).val(outputVal);

    }}

});

problem is, that the functions already replaces the url as soon as “http://www.ab” is typed instead of waiting till space is pressed (complete url, waitig for space, replace with this function). I want to achieve, that people can type in a whole url like http://www.example.org/site?id=1&etcetc before it gets replaced. So I think of “space” as a trigger to start the function. Can someone help me or someone got a better idea?

Thank you so much

wordi

  • 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-23T10:10:55+00:00Added an answer on May 23, 2026 at 10:10 am

    If you want space or whitespace chars to trigger validation, use this:

      $(".url2").keyup(validateOnWhiteSpace).blur(validNum);
    
      function validateOnWhiteSpace() {
        if(event.keyCode == 9 ||  event.keyCode == 13 || event.keyCode == 32) {
            validNum.call(this, arguments);
        }
      }
    
    function validNum() {
    
    var initVal = $(this).val();
    outputVal = initVal.replace(/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])$/,"replace this link by bla..");   
    if (initVal != outputVal) {
        $(this).val(outputVal);
    
        }}
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got this bit of JQUERY: <script> function initNav() { $('.nav tr table td
I've got the following piece of Jquery: $(#collapse-menu > li > a).click(function() { $(this).toggleClass(expanded).toggleClass(collapsed).find(+
i got 'JQuery' is undefined error while browsing the page in IE 6 but
I've got a jquery ajax function that polls the database server to see if
I have got below JQuery where I am performing the .load function. $(.load-fragment).each(function() {
I've got 2 jQuery functions. One calls the other (in theory...). These are: $.testFunction
I have a standard textbox and I've got jQuery on the page. I want
I´ve got a Jquery autocomplete input like the following: $(#cities).autocomplete(regionIDs, { minChars: 2, width:
I've got a jquery json request and in that json data I want to
I've got a jquery script, which creates a h3 tag and print a variable

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.