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

  • Home
  • SEARCH
  • 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 8366481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:55:49+00:00 2026-06-09T12:55:49+00:00

I have had an on-screen keyboard working fine for some time. I recently had

  • 0

I have had an on-screen keyboard working fine for some time.

I recently had to add jQuery to the system and now it does not work any more. Pressing the button does nothing because the text input no longer has the focus when the button is pressed and I cannot refocus on it from my jscript.

The input html (note the use of the excellent jq_watermark – the reason I need jQuery):

<input class="search jq_watermark" id="barcode" name="barcode" type="text" title="Please enter search criteria."/>

Here’s the html for one of the buttons:

<td onclick="addChar('Q')"><button class="osk" id="Key_Q" value="Q">Q</button></td>

Here’s the addChar script. Note the many attempts to focus the field, all fail now jQuery is present:

// The field the keyboard should edit.
field = document.forms['main'].elements.item('barcode');

function addChar(c) {
  console.log("Char("+c+")");
  field.focus();
  if(field.maxLength == -1 || field.value.length < field.maxLength) {
    // Handle different browsers.
    if (field.selectionStart || field.selectionStart == '0') {
      var start = field.value.substr(0,field.selectionStart);
      var end = field.value.substr(field.selectionEnd,field.length);
      field.value = start + c + end;
    } else if (document.selection) {
      field.focus();
      var range = document.selection.createRange();
      range.text = c;
      range.moveStart('textedit',1);
      range.select();
    } else {
      field.value = field.value + c;
    }
    field.focus();
  }
  return false;
}

I had to add this to stop the buttons submitting the form. I suspect this is where I need to put new stuff but being new to jQuery I have no idea what:

$("button.osk").click(function(event){
  // Stop it submitting in case the keyboard is inside a form.
  event.preventDefault();
});

P.S. I am aware of the neat jQuery popup keyboards around and would love to replace mine with theirs but that is not an option right now.

  • 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-06-09T12:55:50+00:00Added an answer on June 9, 2026 at 12:55 pm

    Problem solved:

    It seems the issue was here:

    field = document.forms['main'].elements.item('barcode');
    

    Apparently the arrival of jQuery makes this not work. I have temporarily replaced it with:

    var field;
    $(document).ready(function(){
       field = document.forms['main'].elements['barcode'];
    });
    

    Note that I am wrapping it in a ready function AND not accessing it through items. This does not work in IE8. I will have to fix that.

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

Sidebar

Related Questions

I'm new to working on a Mac and have had Time Machine backing up
I have had the problem a few times now while working on projects and
I'm working on an iOS app and have had some trouble with getting photos
I have had an online archive service for over a year now. Unfortunately, I
I have had this for a couple of days now. I have a simple
I have had a few issues with my apps splash screen, how this stated
I am not worried about screen real estate. They have changed behavior and added
I have had a number of problems with ScrollViews. Recently I tried to create
I have had the Facebook SDK working in the APPDelegate as instructed by the
I have had the Facebook SDK working in the APPDelegate as instructed by the

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.