如果尚未提交表单,则单击禁用LI

时间:2012-02-01 00:39:46

标签: jquery menu alert prompt

如果尚未提交表单,我需要禁用LI菜单项。如果用户试图点击我想要显示的警报,甚至是告诉用户的promt或者为用户提供以下选项

alert("We are sorry as this is a new business lead, you need to save the information first.");

promt("we understand that you want to continue, please click ok for us to save the information you have inputted");

1 个答案:

答案 0 :(得分:0)

很多方法,尝试:

$.ajax({
   ...
   beforeSend: function() {
       if (isMyFormSubmitted()) {
           $('li').click(function() {
               alert('...');
           });
       } else {
           $('li').click(function() {
               prompt('...');
           });    
       }
   }
});

isMyFormSubmitted()是一些返回true或false的函数,具体取决于表单是否已提交。显然,您必须遍历所有字段才能查看该函数中是否有任何更改。

相关问题