faqts : Computers : Programming : Languages : JavaScript : Forms : TextAreas/TextFields

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 10 people (70%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

When submit button is pressed how to replace all commas from textaera with any other letter ?

Dec 20th, 2001 12:10
Arsen Yeremin, Tina Kollen,


<html>
<head>
	<title>Replce text in textarea</title>
  <script>
    function ParseTextArea(obj_textarea, str_replace, str_replace_with)
    {  var tmp_string  = obj_textarea.value;
       tmp_string      = tmp_string.replace
(str_replace,str_replace_with);
       while(tmp_string.search(str_replace) != -1)
       {  tmp_string   = tmp_string.replace
(str_replace,str_replace_with);
       }
       obj_textarea.value = tmp_string;
       alert("Done repacing. We will now submit!")
    }
  </script>
</head>
<body>
  <form onsubmit=" return ParseTextArea(this.my_text, ',', '*')">
    <textarea name="my_text">Yeremin, Arsen ; Doe, John</textarea>
    <br>
    <input type="submit">
  </form>
</body>
</html>