Removing item from Query String after form submission

I have a search form which has some default text Type your search phrase here which currently gets sent as a querystring parameter - the generated URL looks like so:

/search?KeyWords=Type+your+search+phrase+here

However I would like to remove it from the querystring altogether.

At what point should I remove it? I mean, I can check in the controller whether the string matches, and not use it as keywords for the search, but it is still present in the URL and ideally I would like it to be removed entirely so as not to cause any confusion (plus it looks pretty bad having the default phrase in the URL!).

Answers


The semantically correct way to have a default value for a text input field is to use the the HTML5 placeholder attribute instead of setting the value attribute:

@Html.TextBoxFor(x => x.Foo, new { placeholder = "Type your search phrase here" })

In this case the default value won't be sent when the form is submitted.

And if you need to support legacy browsers you could use the jquery.placeholder plugin which will unobtrusively enable support for it.


Need Your Help

New Relic + Wordpress - ignore wp-cron.php

php wordpress newrelic

We have installed New Relic on our server, to monitor the performance of our websites. But recently we want to remove wp-cron.php from New Relic monitoring.

Haskell — How to split a number into a list for further processing?

haskell numbers split

I have an Int that i want to split into it's individual numbers which ideally would be contained in a list, which i can then process further. So i would like something like this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.