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

The Archive Base Latest Questions

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

I am stuck in implementing the following: User starts typing in a textbox. The

  • 0

I am stuck in implementing the following:

  1. User starts typing in a textbox.
  2. The javascript on page captures the first character typed, validates that it is an english alphabet (a-z,A-Z) and converts it to lowercase (if necessary).
  3. Make an XMLHttp request based on the input (i.e. if first input character is a, get a.xml, if b get b.xml and so on).

I know how to do the last part (make the xmlhttp request) but am kind of stuck on how to capture the first character and validate it (in a way that works on all browsers). Please guide. Thanks.

Clarification: This is to create a Google Suggest like autocomplete-drop-down menu without the need for server side programs.

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

    Something like this should work:

    HTML:

    <input type="text" id="myField" />
    

    And in JS:

    window.onload = function() {
        document.getElementById('myField').onkeyup = function() {
            // Validate that the first letter is A-Za-z and capture it
            var letter = this.value.match(/^([A-Za-z])/);
    
            // If a letter was found
            if(letter !== null) {
                // Change it to lowercase and update the value
                letter = letter[0].toLowerCase();
                this.value = letter + this.value.substring(1);
    
                // Do the request
            }
        }
    }
    

    My vanilla-JS skills are a bit rusty but this should do the trick. Just for the heck of it, here’s the same using jQuery:

    $(function() {
        $('#myField').keyup(function() {
            var letter = $(this).val().match(/^([A-Za-z])/);
    
            // If a letter was found
            if(letter !== null) {
                // Change it to lowercase and update the value
                letter = letter[0].toLowerCase();
                $(this).val(letter + $(this).val().substring(1);
    
                // Do the request
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Being stuck with a legacy database schema that no longer reflects your data model
JAVA- Hi, I am writing a minesweeper program (first biggie) and am really stuck.
I am trying to execute a .bat file remotely and implementing following lines of
I am porting Java code in .NET and I am stuck in the following
I've been following a tutorial for implementing auto-complete functionality on my CakePHP 1.3 application.
I read the following in an article Immutable objects are particularly handy for implementing
I've been implementing a barebones observer pattern and am stuck on a somewhat cryptic
I am following Apples Core Data Tutoriol but implementing it into my own Project,
I'm implementing a singly-linked list in C and got stuck with the remove node
I am a bit stuck implementing a rather simple layout requirement. I want 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.