• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
JavaScriptSource

JavaScriptSource

Search 5,000+ Free JavaScript Snippets

  • Home
  • Browse Snippets
    • Addon
    • Ajax
    • Buttons
    • Cookies
    • CSS
    • Featured
    • Forms
    • Games
    • Generators
    • Image Effects
    • Math Related
    • Miscellaneous
    • Multimedia
    • Navigation
    • Page Details
    • Passwords
    • Text Effects
    • Time & Date
    • User Details
Home / Text Effects / Reverse Text Wizard

Reverse Text Wizard

Reverse Text Wizard

Some languages are written from right to left. This script takes the input from the users entry field and simulates typing from right to left using reverse text.

  1. Copy the coding into the HEAD of your HTML document
  2. Add the last code into the BODY of your HTML document
<!– STEP ONE: Paste this code into the HEAD of your HTML document  –>

<HEAD>

<!– This script and many more are available free online at –>
<!– The JavaScript Source!! http://javascriptsource.com –>
<!– Original:  David Hansen ([email protected]) –>
<!– Web Site:  http://www.compswizard.com –>
<script language=javascript>

<!–

function reverseText(tName,fName) {
   if (event.keyCode == 8) {
      eval(“document.” + tName + “.” + fName + “.value = ””);
   }
   if ((event.keyCode == 32) || ((event.keyCode >=48) && (event.keyCode <= 57)) || ((event.keyCode >= 65) && (event.keyCode <= 90)) || ((event.keyCode >= 186) && (event.keyCode <= 222))) {
      text = “”;
      str = eval(“document.” + tName + “.” + fName + “.value”);
      i = 0;
      while (i <= (str.length – 1)) {
         if (i == (str.length – 1)) {
            text = str.substring(i, i+1) + text;
         } else {
            text += str.substring(i, i+1);
         }
         i++;
      }
      eval(“document.” + tName + “.” + fName + “.value = text”);
   }
}

//–>

</script>

</HEAD>
<!– STEP TWO: Copy this code into the BODY of your HTML document  –>

<BODY>

<!– This script and many more are available free online at –>
<!– The JavaScript Source!! http://javascriptsource.com –>
<!– Original:  David Hansen ([email protected]) –>
<!– Web Site:  http://www.compswizard.com –>
<form name=testForm action=”” method=post>

<input name=testField type=text style=”text-align:right” onKeyUp=”reverseText(‘testForm’,’testField’)”>

</form>

<p><center>
<font face=”arial, helvetica” size”-2″>Free JavaScripts provided<br>
by <a href=”https://javascriptsource.com”>The JavaScript Source</a></font>
</center><p>

Text Effects

Related Snippets:

  • Get the direction of the text selection
  • Transform all text in a string to uppercase
  • Get the currently selected text with JavaScript
  • Dynamically changing the text color based on background color contrast

Primary Sidebar

FREE UPDATES!

Get the latest updates in your inbox for FREE!

Popular Posts

Story Generator

IP Grabber – get a users IP address with JavaScript

Simple Calendar

Remove Ads

Astrological Calculator

Copyright © 2023 JavaScriptSource.com

  • About
  • Privacy Policy
  • Submit
  • FAQ
  • Jobs For Developers
  • Contact Us