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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:13:10+00:00 2026-05-17T16:13:10+00:00

I want to capture input charcters in text box, convert then according to a

  • 0

I want to capture input charcters in text box, convert then according to a table and put them back in text box as user types.

<form id='myForm'>

Enter phone number:<input type="text" id='idMyText' name="myText" onKeyUp="alphaToNum(this.value)">
</form>




<script>
// on each keypress in input box, I want to capture key pressed,
// determine if key pressed belong to group of identified characters
// if, so then convert to specified numeric equivalent and return character 
// to text box.
// This mapping corresponds to numeric characters on blackberry device.
// Normally user has to press alt+letter to get numbers. This will provide
// quicker access to numeric characters on for numeric fields

function alphaToNum(e) {
 x = e;
 x = (x.replace(/W/, "1"));
 x = (x.replace(/E/, "2"));
 x = (x.replace(/R/, "3"));
 x = (x.replace(/S/, "4"));
 x = (x.replace(/D/, "5"));
 x = (x.replace(/F/, "6"));
 x = (x.replace(/Z/, "7"));
 x = (x.replace(/X/, "8"));
 x = (x.replace(/C/, "9")); 
 document.getElementById('idMyText').value = x; 
}

</script> 
  • 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-17T16:13:10+00:00Added an answer on May 17, 2026 at 4:13 pm

    Should do the trick.
    Now works wherever caret is and even when you copy/paste WECZ into field (if that matters)

    var conversionMap = {W:1,E:2,R:3,S:4,D:5,F:6,Z:7,X:8,C:9};
    function alphaToNum(){
        var field = document.getElementById('idMyText');
        var value = field.value.split('');
        var i = 0, len = value.length;
    
        for(i;i<len;i++){
            if (conversionMap[value[i]]) {
                value[i] = conversionMap[value[i]];
            }
        }
        field.value = value.join('');
        // prevent memory leak.
        field = null;
    }
    

    ** Edit after Tim Downs comment **

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

Sidebar

Related Questions

I want to capture when a user pastes data into a text input field
I want to capture logs and dump them into a text file, I am
I want to capture the event of a user pressing enter on an input
I have an input like this RX Only : Gi1/0/15,Gi1/0/20,Gi1/0/17 I want to capture
I want to parse user input using named captures for readability. When they type
String input = 2012 AL REG TEXT 300535(NS); String regex = ^((\\d{4})\\s+)?((\\S+)\\s+(.+?)\\s+)\\s+((\\S+)(\\s+\\(.*?\\)))$; I want
I want my application to capture input focus, whenever the mouse hovers over it.
Suppose I have a textbox and I want that when the user types inside
I want to capture the Ctrl + C ( SIGINT ) signal sent from
I want to capture if any changes happened to <textarea> . Like typing any

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.