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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:30:12+00:00 2026-06-10T20:30:12+00:00

I have a form with two inputs: <input type="text" name="keyword" value="Search" onfocus="wipe(this)"/> <input type="text"

  • 0

I have a form with two inputs:

<input type="text" name="keyword" value="Search" onfocus="wipe(this)"/>
<input type="text"  name="city" value="City" onfocus="wipe(this)"/>

and my JavaScript which gets rid of the pre-set value in form field as soon as you click it with your mouse is:

function wipe(obj)
{
obj.value="";
}

My question is, say the user doesn’t type anything in the city field, how do I make it so that when the form is submitted the value for that field is empty and not the word City?

  • 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-10T20:30:14+00:00Added an answer on June 10, 2026 at 8:30 pm

    placeholder is a good attribute which can solve your problem its a past time history when we are used to using value for showing for which this textbox we have

     <input type="text" name="keyword" placeholder="Search" />
    

    if you still want to use java script modify your code something like this

    <input type="text" name="keyword" value="Search" onfocus="wipe(this,'Search')" onblur="wipe2(this,'Search')"/>
    <input type="text"  name="city" value="City" onfocus="wipe(this,'City')" onblur="wipe2(this,'City')"/>
    

    script function for second approch

    function wipe(obj, str)
    {
    if(obj.value!=str){
    obj.value="";}
    }
    
    function wipe2(obj, str)
    {if(obj.value==""){
    obj.value=str;}
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with two input text fields: <input id=ModelName_test_0 name=ModelName[test][0] type=text> <input
I have a form with two text_fields: <input type=text id=post_name name=post[name] /> <input type=text
hey, well I have this form <form method=POST action=''> <input type=hidden name=op value=download1> <input
I have a simple form and inside there are two input fields text type.
I have an input form with two textareas allowing a user to type in
So i have a simple form that takes a few inputs (two text and
i have two text inputs like the following, i don't want to use <form>
I have a form that had live appended input type hiddens with a name,
I have a simple html form with two controls: input-text and input-file I need
I have a form, with the 3 input type text. <input type=text id=one onkeyup=multiply()

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.