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

  • SEARCH
  • Home
  • 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 8519499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:15:58+00:00 2026-06-11T06:15:58+00:00

On my website, I have two input fields: Title & Stock Code. I have

  • 0

On my website, I have two input fields: Title & Stock Code. I have two goals:

  1. The text from the Title field should be be copied to the stock
    code field as the user enters text in the title field.

  2. I also want non-alphanumeric chracters to be stripped out during
    the copy.

I have found this tutorial that explains how to do the first goal.
Here is my working example:

http://jsfiddle.net/2gezC/1/

For the second part, I have found it hard to find a tutorial about stripping characters in Jquery, as most tutorials are for JavaScript.

I have found this tutorial and have tried to integrate it into my code as follows:

(function ($) {
    $(document).ready(function () {

        $('input#edit-title-fragment').keyup(function () {
            var str = $(this).val();
            str = str.replace(/[^a-zA-Z 0-9]+/g, '');
            var txtClone = $(this).val();
            $('input#edit-sku-fragment').val(txtClone);
        });
    });

})(jQuery);

However, it does not work. Could someone tell me what I am doing wrong. Thanks!

  • 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-06-11T06:16:00+00:00Added an answer on June 11, 2026 at 6:16 am

    Here’s what you’re doing:

    // Get the user input from "this" and put it in str variable
    var str = $(this).val();
    // Remove all non alpha-nums from str and store it back in the str variable
    str = str.replace(/[^a-zA-Z 0-9]+/g, '');
    // Get the user input from "this" (yes, again) and put it in the txtClone variable
    var txtClone = $(this).val();
    // Set your other textbox to be the value in txtClone
    $('input#edit-sku-fragment').val(txtClone);
    

    Have you spotted the mistake? You should be setting it to str instead.

    $('input#edit-sku-fragment').val(str);
    

    Which now works: http://jsfiddle.net/2gezC/2/

    Furthmore, as the comments has noted, jQuery is a library built on JavaScript; it’s written in JavaScript itself, as you can see by browsing it’s source code; https://github.com/jquery/jquery

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two regular expressions for one user input field that should accept a
I have two things i want to do to this input text field. <input
I have a form where depending on the website's brand one of two input
I have a login form for my website. This login form have two text
I have this code for Jaro-Winkler algorithm taken from this website. I need to
If I have an international website and I have two clients: client from Spain.
In my website, user have to upload a file, and should have two buttons
I have an input field on a website I am making with a jquery
My code has two forms that create a text field for both username and
I have a website I'm building with two user streams. I have the code

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.