单击按钮,我想验证数据,如果为真,我想要删除确认对话框.这可能吗?

On click of button, I want to validate the data and if true i want the delete-confirmation dialog.. Is it possible?

本文关键字:对话框 确认 删除 我想要 按钮 验证 数据 如果 单击      更新时间:2023-09-26

我有两个日期选择器,from date和to date,以及一个删除按钮。在点击删除,验证应该完成,如果从日期大于日期等,然后删除确认弹出窗口应该显示是或否。如果单击yes,则应该调用delete回调函数,否则将返回false!

怎么做??如有任何帮助,不胜感激

我的代码

"#Delete click": function(el, ev) {
  this.validate();
  this.confirmation("#Delete", "Are you sure?", "Yes", "No", this.deleteConfirmCallback, this);
},
confirmation: function(element, text, yesText, noText, yesCallback, context) {
  $(element).confirmation({
    title: text,
    singleton: true,
    popout: true,
    btnOkClass: "btn btn-sm default-color",
    btnCancelClass: "btn btn-sm primary-color text-case ",
    btnOkLabel: yesText,
    btnCancelLabel: noText,
    btnOkIcon: "glyphicon-tiny glyphicon-ok",
    btnCancelIcon: "glyphicon-tiny glyphicon-remove",
    onConfirm: function() {
      yesCallback(context, this);
    }
  });    
},

引用

第一次点击时无法弹出删除确认窗口

引用

试试这样做:

if('#btn').click(function(){
    if($('#fromDate').val() > $('#toDate').val())  
    // You can also make a function to check this and call it here
    {
        // Open delete confirm
        // Check if user select OK or cancel and make an ajax call to delete if use select delete option
    }
});

您可以这样尝试:

var from_date = $("#from_date").val();
var to_date = $("#to_date").val();
if(from_date > to_date) {
   //true condition statement
   // should be alert or confirmation
} else {
   //false condition statement
   // should be alert or confirmation
}