开发者

Jquery and Dialog Validation

开发者 https://www.devze.com 2022-12-16 18:23 出处:网络
I am having one hell of a time trying to get this to work, no javascript errors what so ever. Its just going right to the action. Here is the javascript I am using

I am having one hell of a time trying to get this to work, no javascript errors what so ever. Its just going right to the action. Here is the javascript I am using

$(function(){

      $("form[name=form1]").submit(function(){
          return $("#dialog").dialog({
              autoOpen:false,
              bgiframe: true,
              resizable: false,
              //height:auto,
              width:500,
              modal: true,
              overlay: {
                  backgroundColor: '#000',
                  opacity: 0.5
              },
              buttons: {
                  'I Agree': function() {
                      $(this).dialog('close');
                      return true;
                  },
                  'I Do Not Agree': function() {
                      $(this).dialog('close');
                      return false;
                  }
              }
          });     
    });  开发者_StackOverflow社区       

});


The problem is that the dialog method you are calling returns immediately and the buttons functions are called asynchronously, when the buttons are clicked. I suggest that you attach a simple click event to your submit button. The click event will open the dialog and the 'I agree' function will submit the form.


I had to put the submit button outside of the <form></form> tags.

0

精彩评论

暂无评论...
验证码 换一张
取 消