English 中文(简体)
在一个表格之外使用一个纽芬兰语提交表格,并触发 j鉴定
原标题:Using a button outside a form to submit form and trigger jQuery validation

采用j Query 鉴定金和表格的Im 采用Ajax 提交表格。 我有一个浮动的纽芬兰酒吧,它根据该网页的使用情况,为网页生成纽芬兰语。 这些纽芬兰人坐在tag子之外。 我的表格是开明账户。 我的文件。 我准备这样做:

$("#account-settings").validate({
        rules: {
              email: {email: true}
               },

         messages: {
                      email: {email: "Enter a valid email address."}
               },
    })

有一个叫做“储蓄”的州,为形式节省了环境。 这里点击事件:

$( #savesettings ).click(function() {  

 if($( #account-settings ).valid()){
    alert("Valid form");
}
else{
    alert("Not valid");
}
}

当我点击纽子......,基本上,我显然不使用原始权利,有些人向我开了吗? 阅读文件,但我看不到其他东西......

最佳回答

您将需要在点击 but子的用户上将表格序列化。

$( #savesettings ).click(function() {  

 var $as = $( #account-settings );

 if($as.valid()){

    $.post(
        /* your server page */
      , $as.serialize()
      , /* your callback function */
    );

  }

  else{
    alert("Not valid");
  }

});

我应该指出,显然可以提供一种形式,使没有 Java本的用户无法使用。

问题回答

如果你想要提交使用该表外任何纽子的表格,你就应当使用<代码>trigger()这样的功能:

$( body ).on( click ,  #my-button , function(){
    $( #account-settings ).trigger( submit );
});

之后,你的验证金应当正常。

您的《共同提交文件》职能可使用一个封闭区。 类似:

$( #savesettings ).click(function() {  
  if($( #account-settings ).valid()){
    alert("Valid form");
  } else {
    alert("Not valid");
  }
});




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签