title: How do you prevent user resubmitting the same search criteria again and again
body: <p>I have the following javascript to prevent the user from resubmitting the same search criteria without changing the text (SearchString) or the combo box (SearchType).  The EnableSubmit works but has a problem that when the user adds and then removes a space, EnableSubmit falls over.  </p>
  
  <p>I try to keep the value of the last criteria in LastChange variable.  Then when they submit it again, the alert box pops up.  After the alert is closed, the code then looks like it is submitting and then they can then reclick submit with the same previous criteria.  The question is, how can I after the alert box close then keep LastChange with the same value.  </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      var LastChange;
  
      $("#SearchString").change(function () { EnableSubmit();});
      $("#SearchString").keyup(function () { EnableSubmit(); });
      $("#SearchType").change(function () { EnableSubmit(); })
  
      function EnableSubmit () { $("#SubmitButton").removeAttr("disabled"); $("#SubmitButton").attr("value", "Search"); }
  
      $(function () {
  
      $("#StarForm").submit(function (e) { 
  
          $("#SubmitButton").attr("disabled", true);
          $("#SubmitButton").attr("value", "Submit disabled until you change search criteria.");
  
          if (LastChange == ($("#SearchString").val())) {
              alert('Please change the search criteria before resubmitting.');
              LastChange = ($("#SearchString").val());
  
          }
          else {
  
              LastChange = ($("#SearchString").val());
  
  
  
              var FormData = '{ "SearchString": "' + $('#SearchString').val() + '",' +
                  '"SearchType" : "' + $('#SearchType').val() + '"' +
                  '}';
              e.preventDefault();
  
          }
  
      });
  
  });
  &lt;/script&gt;
  </code></pre>