title: Stop page from reloading after alert in if statement
body: <p>I am facing this issue here.After i click alert in if statement the page should not reload.I have tried everything here </p>
  
  <ol>
  <li>return false;</li>
  <li>event.preventDefault();
  3.window.stop();//This is working but for other conditions where page should reload it is not getting loaded.
  4.return; </li>
  </ol>
  
  <p>So as you can see in if statement when <code>sel.options[sel.selectedIndex].text!="Meeting Room Name</code> the alert is showed after i click ok the page should not reload.I have tried each and every solution and referred many posts.</p>
  
  <pre><code>  $("input[id$='diidIOSaveItem']").click(function(ev) 
  {
      var startDate = $("input[id$='DateTimeField_DateTimeFieldDate']")[0].value;
      var EndDate = $("input[id$='DateTimeField_DateTimeFieldDate']")[1].value;
      var startH = $("select[id$='DateTimeFieldDateHours']")[0].value;
      var endH = $("select[id$='DateTimeFieldDateHours']")[1].value;
      var startM = $("select[id$='DateTimeFieldDateMinutes']")[0].value;
      var endM = $("select[id$='DateTimeFieldDateMinutes']")[1].value;
      var meetingTitle = $("input[id$='TextField']").val();
  
      if(meetingTitle == "" || meetingTitle == "undefined")
      { 
      alert("You have not entered a Meeting Title.");
      $("input[id$='TextField']").focus();
      }
  
  
      if(startDate != EndDate)
      {
      alert("Each Meeting must start and finish on the same day.");
      $("input[id$='DateTimeField_DateTimeFieldDate']").focus();
      }
      if(startH == endH &amp;&amp; startM == endM) 
      {
      alert("End Hour/Minutes and Start Hour/Minutes can not be same.");
      $("select[id$='DateTimeFieldDateHours']").focus();
      }
  
      if(startH &gt; endH ) 
      {
      alert("End Hour must be greator than or equal to Start Hour.");
      $("select[id$='DateTimeFieldDateHours']").focus();
      }
       if(sel.options[sel.selectedIndex].text =="Meeting Room Name")   //if no meeeting room or more then one meeting room is selected.
              {
                  alert("Please select One Meeting Room");
  
                  //$("input[id$='DateTimeField_DateTimeFieldDate']").focus();    
                  // ev.preventDefault();         
                  return false;   
              }
  
      if(sel.options[sel.selectedIndex].text!="Meeting Room Name")
      {           
              //if without any room selection clicking on save.
              if(selectedValue.length == 1)
              {
                  if(selectedValue.options[selectedValue.selectedIndex] != "undefined")
                  {
                      selectedValueres= selectedValue.options[selectedValue.selectedIndex].text;
                      //sel.options[sel.selectedIndex].text= selectedValueres ;
                      if((selectedValueres != "")&amp;&amp;(selectedValue.length == 1))
                      {console.log("selectedValueres  "+ selectedValueres);
                          if (!PreSaveItem())return false;
                          WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ctl40$g_2543e208_7ccd_45b5_9c3c_703dd452cee7$savebutton2$ctl00$diidIOSaveItem", "", true, "", "", false, true));
                      }
                      else    //if no meeeting room or more then one meeting room is selected.
                      {
                          //alert("Please refresh page and click on new booking your booking is conflict with other user.");      
                      GipAddSelectedItemsModified(ctl00_ctl40_g_2543e208_7ccd_45b5_9c3c_703dd452cee7_ff41_ctl00_ctl00_MultiLookupPicker_m); 
                          selectedValueres= $("tr.tobehide select[id$='SelectResult']").find(":selected").text();
  
                  $("&lt;option value='new value' selected='selected'&gt;"+selectedValueres+"&lt;/option&gt;").prependTo($("tr.tobehide select[id$='SelectCandidate']")); 
  
                      }
                      //sel.options[sel.selectedIndex].text= selectedValueres ;
                  }
                  else    //if no meeeting room or more then one meeting room is selected.
                  {
                      alert("Please select One Meeting Room");        
                      return;
  
                  }
               }
  
              }
  
          return false;
  
  });
  </code></pre>