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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:57:35+00:00 2026-06-03T04:57:35+00:00

hi i am using javascript function to balnk ma textboxes when its clicked, initially

  • 0

hi i am using javascript function to balnk ma textboxes when its clicked, initially the text boxes contain their respective label names, eg: Client Name, Company etc. When the text box is clicked it makes the text box empty so data can be types. for this i am using a javascript function and for each textbox i have to have a seperate function, can anyone tell me how i can combine all these function, the only different thing in each function is the value used in the textbox and the textbox name.

The Javascript function

    function clientnameclear() {
    if(document.bunkerfrm.clientname.value=="Client Name") {
        var bunkerfrm = document.bunkerfrm.clientname.value="";
        var bunkerfrm = document.bunkerfrm.clientname.focus();
    }
    else {
        var bunkerfrm = document.bunkerfrm.clientname.focus();
    }
}

function clientnamereset() {
    if(document.bunkerfrm.clientname.value=="") {
        var bunkerfrm = document.bunkerfrm.clientname.value="Client Name";
    }
}

function vesselnameclear() {
    if(document.bunkerfrm.vesselname.value=="Vessel Name") {
        var bunkerfrm = document.bunkerfrm.vesselname.value="";
        var bunkerfrm = document.bunkerfrm.vesselname.focus();
    }
    else {
        var bunkerfrm = document.bunkerfrm.vesselname.focus();
    }
}

function vesselnamereset() {
    if(document.bunkerfrm.vesselname.value=="") {
        var bunkerfrm = document.bunkerfrm.vesselname.value="Vessel Name";
    }
}

function compclear() {
    if(document.bunkerfrm.company.value=="Company") {
        var bunkerfrm = document.bunkerfrm.company.value="";
        var bunkerfrm = document.bunkerfrm.company.focus();
    }
    else {
        var bunkerfrm = document.bunkerfrm.company.focus();
    }
}

function compreset() {
    if(document.bunkerfrm.company.value=="") {
        var bunkerfrm = document.bunkerfrm.company.value="Company";
    }
}

The Html Code is

<form name="bunkerfrm" id="bunkerfrm" action="#" method="post"><br>
<input type="text" name="clientname" class="txtbox" value="Client Name" onmousedown="clientnameclear()" onclick="clientnameclear()" onblur="clientnamereset()" />
<br /><br>
<input type="text" name="company" class="txtbox" value="Company" onmousedown="compclear()" onclick="compclear()" onblur="compreset()" />
<br /><br>
<input type="submit" name="submitting" class="bunksubmit" value="Send Your Inquiry" /><br>
 </form>
  • 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-03T04:57:36+00:00Added an answer on June 3, 2026 at 4:57 am

    I suggest you use and/or study existing libraries, such as:

    • In-Field http://fuelyourcoding.com/scripts/infield/
    • ClearField http://labs.thesedays.com/projects/jquery/clearfield/
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a canvas that I am using a javascript function to display text
I am opening a link in a new window using jQuery: <script type=text/javascript> $(document).ready(function()
Using the javascript function function squareIt(number) { return number * number; } When given
I'm using a javascript function to submit my form. This works in every browser
I am using this JavaScript function in order to change image on click, but
I am having trouble using a javascript function in my wp7 application. I am
Using javascript I'm looping through my H3 elements like this: $('h3').each(function(){ }); I'm then
I call a javascript function from a textbox by using OnKeyPress=clickSearchButton() Here is my
I wish to execute a javascript function after asp.net postback with out using ajax.
I want to execute any JavaScript function that is part of a JSON using

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.