title: how to force user to insert some value into a @htmel.textbox using jquery in mvc
body: <p>i have a search page in which i want to force user to insert some valid input using jquery what i was trying is not working, please help.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
          $('#btn-gn').click(function () {
              if ($('#firstName').length == 0) {
                  alert("please enter username");
              }
              $.ajax({
                  url: '@Url.Action("Search","User")',
                  type: 'POST'
                  success: function (result) {
                      alert("success");
                  },
                  error: function (result) {
                      alert("error!");
                  }
              });   //end ajax
          });
  &lt;/script&gt;
   @using (Html.BeginForm("Search", "User", FormMethod.Post))
      {
          @Html.AntiForgeryToken()
  
    @Html.TextBox("firstName", null, new { @class = "complete" })
   @Html.TextBox("lastName", null, new { @class ="complete" })
    &lt;button type="submit" id="btn-gn"&gt;submit&lt;/button&gt;
  
      }
  </code></pre>
  
  <p>any help will be appreciated..</p>