I'm working on building a search engine in my application, and because I don't want to have a Querystring in my URL, I'm currently using Javascript to submit the searchTerms for me.
Basically I am NOT using a "form", but rather just an input
<input id="searchBox" class="search" name="searchTerm" tabindex="1" onfocus=" this.className = 'search-alt'; if (this.value=='search...') this.value = ''" type="text" onkeypress="searchKeyPress(event,this.form)" maxlength="80" size="28" value="search...">
<script type="text/javascript">
function searchKeyPress(e, form) {
var key = e.keyCode || e.which;
if (key == 13) {window.location.href = '<%: url.Content("~/search") %>/' + $('#searchBox').val();}}
</script>
The problem with this method is "two fold"
- If the user doesn't have Javascript, the form will not submit
- I'm not sure if a search engine will be able to use this search form either
So my question is
Can I use a Form element on my page that can submit " http://example.com/search/{searchTerms} " instead of " http://example.com/search/?q={searchTerms} " while NOT using Javascript?
I'm using ASP.NET MVC 2