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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:56:33+00:00 2026-06-06T20:56:33+00:00

I have just started using Phonegap, I wanted to clear the textbox content when

  • 0

I have just started using Phonegap, I wanted to clear the textbox content when the user clicks on the textbox.

HTML:

<input type="text" class="clear" id="dateVal" name="date" value="date" onblur="clear();"/>/

JavaScript

function clear() {
        document.getElementsByTagName('input').value = '';
    }

But the clear function is not getting called. Also, just tried putting alert in clear()
function(did not help). Everything else working okay. Any help would be appreciated.

Full HTML Code:

<!DOCTYPE html> <html>   <head>
    <title>Age Calculator</title>

    <script type="text/javascript" charset="utf-8" src="cordova-1.8.1.js"></script>
    <script type="text/javascript" charset="utf-8">
      document.addEventListener("deviceready",onDeviceReady,false);

    function onDeviceReady() { 
        alert('welcome');
    }
        function calAge() {         
          var x = confirm('Click here to calculate the age'); 
          if(x == true) {
           document.getElementById('ageId').style.display = block';
          } else {
              navigator.app.exitApp();      }
         }   
        function submitValues() {
                var todaysDate = new Date();
                var y = todaysDate.getFullYear();
                var m = todaysDate.getMonth() + 1;
                var d = todaysDate.getDate() + 1;
                var myYear = document.getElementById('yearVal').value;
                var myMonth = document.getElementById('monthVal').value;
                var myDate = document.getElementById('dateVal').value;
                var myYear = (y-myYear);
                var myMonth = (m-myMonth);
                var myDate = (d-myDate);
                document.getElementById('ageId').style.display = 'none';    
                document.getElementById('result').innerHTML = 'You are '+myYear+'years '+myMonth+' months and '+myDate + ' days old :-)';
                            }   function clear() {      document.getElementsByTagName('input').value = '';  }
    </script>   </head>   <body>
    <button onclick="calAge();">Age Calculator</button> <br>
    <div id="ageId" style="display:none;">
        <b>Please Enter your Date Of Birth in (dd/mm/yyyy) format:</b>
        <input type="text" class="clear" id="dateVal" name="date" value="date" onblur="clear();"/>/
        <input type="text" class="clear" id="monthVal" name="month" value="month" />/
        <input type="text" class="clear" id="yearVal" name="year" value="year" />
        <input type="button" value="submit" onclick = "submitValues();" />
    </div>
    <div id="result">
    </div>   </body> </html>
  • 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-06T20:56:35+00:00Added an answer on June 6, 2026 at 8:56 pm

    In HTML5 there is a placeholder attribute.
    Ex:

    <input type="text" placeholder="Enter Date" id="dateVal" name="date" />
    

    We could use this to get what I desired.
    Thanks, might be helpful to somebody.

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

Sidebar

Related Questions

I have just started using Html.RenderPartial(usercontrol, model) to render my user controls. Is it
I have just started using phonegap, and my application demands an use of a
I have just started using flexigrid and wanted to use the resource string to
i have just started using Moq ver (3.1) and i have read blogs and
I have just started using jQuery and although following code gets the job done,
I have just started using the Data Access Application Block from microsoft. There are
I have just started using C2DM. I prefer to send REGISTRATION intent only once
I have just started using Vim in a terminal (PuTTY or MinTTY), after always
Let me preface this question. I have just started using jquery, so please be
I just started using php arrays (and php in general) I have a code

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.