0

What are all the triggers that will trigger the submit if I have a page that has this form on it?

*NOTICE - I only have a text field and NO submit button.

Will the submit occur when I press enter and the cursor is in the text field?

@using (Html.BeginForm("Search", "Home", FormMethod.Get, new { @class = "navbar-form navbar-left", role = "search", id = "queryWithin" })) {
<div class="form-group">
  <input type="text" class="form-control" placeholder="Search" id="searchQuery" name="searchQuery">
</div>

}
chuckd
  • 13,460
  • 29
  • 152
  • 331

2 Answers2

0

If you don't have button at all - no your form will not submit.

You either should use javascript for submit on enter press event or there is a really neet hack how you can hide your submit button from user, but don't hide it from key press event.

Just quote solution here:

<input type="submit" style="position: absolute; left: -9999px"/>
Community
  • 1
  • 1
teo van kot
  • 12,350
  • 10
  • 38
  • 70
0

I don't think so , you should have submit button and also your form method should be FormMethod.Post not FormMethod.Get

Elyana
  • 21
  • 2
  • 1
    Isnt the difference between GET and POST in the way the URL is generated , caching of parameter, data length, etc. Is there a specific reason why you want the user to use POST as opposed to GET? – mahlatse Aug 20 '15 at 05:18
  • maybe this link would be helpful : http://stackoverflow.com/questions/3477333/what-is-the-difference-between-post-and-get – Elyana Aug 20 '15 at 05:56