title: how to stop function save in jquery
body: <p>When Save button clicked, I want to make sure date exist or not.</p>
  
  <p>I tried to use return false , <code>e.stopPropagation()</code> , <code>e.stopImmediatePropagation()</code> and none of those works to stop execute <code>saveEvent</code>. As you can see in my example, button save  will always be executed. I want to stop that stop the <code>SaveEvent</code> . Could you help?</p>
  
  <pre><code>       $('#btnSave').click(function () {
  
                  var StartDate = $('#txtStart').val();
  
                  $.ajax({
                      type: "POST",
                      url: "/Home/Checkdate",
                      data: '{StartDate: "' + StartDate + '" }',
  
                      contentType: "application/json; charset=utf-8",
                      dataType: "json",
                      success: function (response) {
                          var message = $("#message");
                          if (response) {
                              //Email available.
                              message.css("color", "green");
                              message.html(" date is not exist ");
                          }
                          else {
                              message.css("color", "red");
                              message.html("date existe ");
                              alert('date existe');
  
                              return;
  
                          }
  
                      }
                  });
  
  
           var data = {
  
                      EventID: $('#hdEventID').val(),
                      EventTitle: $('#txtSubject').val().trim(),
                      StartDate: $('#txtStart').val().trim(),
                      EndDate: $('#chkIsFullDay').is(':checked') ? null : $('#txtEnd').val().trim(),
                      EventDescription: $('#txtDescription').val(),
                      ThemeColor: $('#ddThemeColor').val(),
                      IsFullDay: $('#chkIsFullDay').is(':checked')
                  }
  
                      SaveEvent(data);
  
  
  
                  // call function for submit data to the server
              })
  </code></pre>