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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:32:59+00:00 2026-05-28T15:32:59+00:00

How can i have default values for my input’s, and when user submites form,

  • 0

How can i have default values for my input’s, and when user submites form, only values from changed inputs go to query, those that havent been change don’t?

I have:

@using (Ajax.BeginForm("Search", "Persons", new AjaxOptions
{
   HttpMethod = "POST",
   InsertionMode = InsertionMode.Replace,
   UpdateTargetId = "results",
   LoadingElementId = "progress"
}))

{
<input name="Name" type="text" class="cleardefault" value="First and Last name"/>
<input name="Adress" type="text" class="cleardefault" value="Adress"/>

<input name="Search" type="submit" class="mainSearchSubmit" value="submit" />  
} 

I am using functions for clearing and replacing default text in
<input> elements, by Ross Shannon, http://www.yourhtmlsource.com/

My goal is to only send values that are not default? This way when i breakpoint to my controller, my query has default values inside?? Is there a way to resolve this, and still keep MVC3 native code?

Any ideas?

  • 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-05-28T15:33:00+00:00Added an answer on May 28, 2026 at 3:33 pm

    Full answer: from hagenburger.net

    HTML

    <input type="text" placeholder="Fill me …">
    

    JS

    //for older browsers
    
    $('[placeholder]').focus(function() {
         var input = $(this);
         if (input.val() == input.attr('placeholder')) {
             input.val('');
             input.removeClass('placeholder');
         }
    }).blur(function() {
        var input = $(this);
        if (input.val() == '' || input.val() == input.attr('placeholder')) {
            input.addClass('placeholder');
            input.val(input.attr('placeholder'));
        }
    }).blur();
    
    
    $('[placeholder]').parents('form').submit(function() {
        $(this).find('[placeholder]').each(function() {
            var input = $(this);
            if (input.val() == input.attr('placeholder')) {
                 input.val('');
            }
        })
    });
    

    CSS

    .placeholder
    {
        color: #aaa;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have in input box that can only contain numerical values (with use of
How can I have a localized default values in the Settings bundle? I encounter
I have a default IIS 6 install and I can access only .html files.
I've got a form setup with 2 text boxes that have default values that
I have a script which dynamically adds rows to a form with default values:
My forms have inputs with default helper text that guides the user on what
I have registration form on my website that, using jquery I append default values
As title, how can I set a table's column to have the default value
My client can't read iPhone's default fonts, the size is too small. I have
I have a form in my HTML page, containing a label, an input field

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.