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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:16:46+00:00 2026-05-24T21:16:46+00:00

I have a form with multiple text areas. <textarea name=datasetname_1 cols=40 rows=5 id=datasetname_1 class=validate[required]

  • 0

I have a form with multiple text areas.

<textarea name="datasetname_1" cols="40" rows="5" id="datasetname_1" class="validate[required] text-input"></textarea><br>
<textarea name="datasetname_2" cols="40" rows="5" id="datasetname_2" class="validate[required] text-input"></textarea><br>
<textarea name="datasetname_3" cols="40" rows="5" id="datasetname_3" class="validate[required] text-input"></textarea><br>

I would like to replace any text that contains commas with dashes. This should work for text that’s typed directly in the text areas or text that is pasted over. The text should be replaced before the form is submitted. How can I accommplish this with jquery or javascript?

I have tried this

    $("#formID").submit(function() {
  $("textarea").each(function() {
($(this).val().replace(',','-'));
  });
  });

with no luck.

  • 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-24T21:16:47+00:00Added an answer on May 24, 2026 at 9:16 pm
    $(this).val().replace(',','-');
    

    will fetch the value, replace one comma with a hyphen and then does nothing because you don’t store the value into a variable.

    Instead, you can use:

    1. $(this).val('some value'); to actually set the value.
    2. Use a regular expression to replace all occurences.
    3. (Properly indenting your code helps a lot in general.)

    E.g.: http://jsfiddle.net/pimvdb/HsFbN/.

    $("#formID").submit(function() {
      $("textarea").each(function() {
        $(this).val($(this).val().replace(/,/g, "-"));
      });
    });
    

    It is arguable whether jQuery should be used for everything, but you can also omit it here:

    $("#formID").submit(function() {
      $("textarea").each(function() {
        this.value = this.value.replace(/,/g, "-");
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this text input in a form: <input type=text cols=40 rows=5 style=width:200px; height:50px;
I have form with multiple input type=radio with text next to them. I want
if i have one form that include some input, textarea, select, and multiple file.
In my form, I have a TextArea Box in which user can input multiple
so I have a form that I have multiple input text fields as well
I have a form with multiple rows of text boxes. I use jquery .show()
I have an HTML form with multiple text inputs. I want to clear the
I have a form where I've got multiple text inputs for various timefields, each
I have a form with multiple fields that I'm validating (some with methods added
I have a form with multiple dropdowns consisting of multiple values. I'm trying to

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.