2016-11-16 10 views
0

私のコードは次のとおりです。ストップjqueryの-UI DatePickerの確認ボックス

HTML、

Date : <input id="datepicker"> 
Fare : <input id="fare"> 

JS、

<script> 
    $(function(){ 
     $("#datepicker").datepicker({ 
      changeMonth: true, 
      changeYear: true, 
      showAnim: 'clip', 
      dateFormat: "yy-mm-dd" 
     }).val(); 
    }); 


    $("#datepicker").click(function() { 
     if (confirm("If you change the Date the Fare fields data will be deleted !!")) { 
      $('#fare').val(''); 
     } else { 
      return false; 
      $("#datepicker").datepicker('destroy'); 
     } 
    }); 
<script> 

私は取り消したときに、私は日付ピッカーを停止しようとしています確認ボックス。 Unfortunetlyその動作しません。助けてください。

答えて

0

falseを返して、datepickerを破棄しています。

逆である必要があります。これを試してみてください:

$("#datepicker").click(function() { 
    if (confirm("If you change the Date the Fare fields data will be deleted !!")) { 

     $('#fare').val(''); 

    }else{ 
     $("#datepicker").datepicker('destroy'); 
     return false; 
    } 
}); 
0

まず、その後、return falseを行う破壊し、

<script> 
$(function(){ 
    $("#datepicker").datepicker({ 
     changeMonth: true, 
     changeYear: true, 
     showAnim: 'clip', 
     dateFormat: "yy-mm-dd" 
    }).val(); 
}); 


$("#datepicker").click(function() { 
    if (confirm("If you change the Date the Fare fields data will be deleted !!")) { 
     $('#fare').val(''); 
    }else{ 
     $("#datepicker").datepicker('destroy'); 
     return false; 
    } 
});