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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:29:12+00:00 2026-06-05T08:29:12+00:00

I need to change the back button functionality of my phonegap project, which I’ve

  • 0

I need to change the back button functionality of my phonegap project, which I’ve succeeded in doing without any problem. The only issue now, is that I need to further change the functionality based on if the user has a certain field selected.

Basically, if the user has clicked in a field with the id of “date-selector1”, I need to completely disable the back button.

I was attempting to use document.activeElement, but it only returns the type of the element (input in this case), but I still want the functionality to work when they are in a general input, but not when they are in an input of a specific id.

EDIT
I tried all of the suggestions below, and have ended up with the following code, but still no success.

function pluginDeviceReady() {
document.addEventListener("backbutton", onBackKeyDown, false);
}

function onBackKeyDown() {
    var sElement = document.activeElement;
    var isBadElement = false;
    var eList = ['procedure-date', 'immunization-date', 'lab-test-done', 'condition-onset', 'condition-resolution', 'medication-start-date', 'medication-stop-date', 'reaction-date'];
   console.log("[[ACTIVE ELEMENT: --> " + document.activeElement + "]]");
   for (var i = 0;i < eList.length - 1;i++) {
        if (sElement == $(eList[i])[0]) {
            isBadElement = true;
        }
    }
    if (isBadElement) {
        console.log('Back button not allowed here');
    } else if ($.mobile.activePage.is('#main') || $.mobile.activePage.is('#family') || $.mobile.activePage.is('#login')) {
        navigator.app.exitApp();
    } else {
        navigator.app.backHistory();
    }
}
  • 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-05T08:29:13+00:00Added an answer on June 5, 2026 at 8:29 am

    if you’re listening for the back button you can add this if statement:

    if (document.activeElement == $("#date-selector1")[0]) { 
        /*disable button here, return false etc...*/ 
    }
    

    or even better (Thanks to Jonathan Sampson)

    if (document.activeElement.id === "date-selector1") { 
        /*disable button here, return false etc...*/ 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to change the default title value of the back button in a
I need to change a part of my web page content dynamically without refreshing
Ok folks, basically I need to change the value of the input (which is
Need to change image back ground when click on HREF with other function <a
Need to specify a ID and its changed class name to change it back.
I need change background of all text that have two spaces from the start
i need change color of SystemTray.ProgressIndicator color, how i can do it? I tried
I have database, and in one the tables I need change the values of
I use Pjax with tutorial from http://railscasts.com/episodes/294-playing-with-pjax?view=comments I don't need change url and this
Need to change li position by clicking to move up or to move down.

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.