• <tfoot id='DTCI8'></tfoot>
    <i id='DTCI8'><tr id='DTCI8'><dt id='DTCI8'><q id='DTCI8'><span id='DTCI8'><b id='DTCI8'><form id='DTCI8'><ins id='DTCI8'></ins><ul id='DTCI8'></ul><sub id='DTCI8'></sub></form><legend id='DTCI8'></legend><bdo id='DTCI8'><pre id='DTCI8'><center id='DTCI8'></center></pre></bdo></b><th id='DTCI8'></th></span></q></dt></tr></i><div id='DTCI8'><tfoot id='DTCI8'></tfoot><dl id='DTCI8'><fieldset id='DTCI8'></fieldset></dl></div>
    <legend id='DTCI8'><style id='DTCI8'><dir id='DTCI8'><q id='DTCI8'></q></dir></style></legend>

        <small id='DTCI8'></small><noframes id='DTCI8'>

        • <bdo id='DTCI8'></bdo><ul id='DTCI8'></ul>

        仅当表单有效时如何触发 jQuery 函数

        How to fire jQuery function only if form is valid(仅当表单有效时如何触发 jQuery 函数)
        <tfoot id='VgiWp'></tfoot>

        <i id='VgiWp'><tr id='VgiWp'><dt id='VgiWp'><q id='VgiWp'><span id='VgiWp'><b id='VgiWp'><form id='VgiWp'><ins id='VgiWp'></ins><ul id='VgiWp'></ul><sub id='VgiWp'></sub></form><legend id='VgiWp'></legend><bdo id='VgiWp'><pre id='VgiWp'><center id='VgiWp'></center></pre></bdo></b><th id='VgiWp'></th></span></q></dt></tr></i><div id='VgiWp'><tfoot id='VgiWp'></tfoot><dl id='VgiWp'><fieldset id='VgiWp'></fieldset></dl></div>

              <tbody id='VgiWp'></tbody>
            <legend id='VgiWp'><style id='VgiWp'><dir id='VgiWp'><q id='VgiWp'></q></dir></style></legend>

              <small id='VgiWp'></small><noframes id='VgiWp'>

                • <bdo id='VgiWp'></bdo><ul id='VgiWp'></ul>
                  本文介绍了仅当表单有效时如何触发 jQuery 函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个与我的提交按钮相关联的 jQuery 函数,如下所示:

                  I have a jQuery function tied to my submit button like this:

                  $(function () {
                      $('#signupform').submit(function () {
                          alert('test');
                      });
                  });
                  

                  但是,无论表单是否有效,它都会触发.我的模型装饰有各种 DataAnnotations 并且客户端验证运行良好,但我只希望 jQuery 函数在表单经过验证时触发.我该如何做到这一点?

                  However, it fires whether or not the form is valid. My model is decorated with various DataAnnotations and the client-side validation is working well, but I only want that jQuery function to fire if the form has been validated. How do I accomplish that?

                  为了澄清,我使用 MVC DataAnnotations + jQuery 的不显眼的 javascript 来处理客户端验证.我没有编写自己的 javascript 验证例程.内置的 jQuery 验证在验证表单方面做得很好,但我只需要知道如何在我自己的函数中将该验证的结果转换为布尔值.

                  To clarify, I'm using MVC DataAnnotations + jQuery's unobtrusive javascript to handle the client-side validation. I do not have my own javascript validation routines written. The built in jQuery validation is doing a great job of validating the form, but I just need to know how to get the results of that validation into a boolean value within my own function.

                  推荐答案

                  如果你使用 jquery validate 不显眼的验证,你可以:

                  If you are using jquery validate unobtrusive validation you could:

                  $(function () {
                      $('#signupform').submit(function () {
                          if($(this).valid()) {
                              alert('the form is valid');
                          }
                      });
                  });
                  

                  这篇关于仅当表单有效时如何触发 jQuery 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Pause youtube video, youtube api(暂停 youtube 视频,youtube api)
                  Youtube iframe api not triggering onYouTubeIframeAPIReady(Youtube iframe api 未触发 onYouTubeIframeAPIReady)
                  How can I stop a video with Javascript in Youtube?(如何在 Youtube 中停止使用 Javascript 的视频?)
                  How to call Greasemonkey#39;s GM_ functions from code that must run in the target page scope?(如何从必须在目标页面范围内运行的代码中调用 Greasemonkey 的 GM_ 函数?)
                  How do you mute an embedded Youtube player?(如何使嵌入式 Youtube 播放器静音?)
                  How to get number of video views with YouTube API?(如何使用 YouTube API 获取视频观看次数?)
                  • <i id='240q7'><tr id='240q7'><dt id='240q7'><q id='240q7'><span id='240q7'><b id='240q7'><form id='240q7'><ins id='240q7'></ins><ul id='240q7'></ul><sub id='240q7'></sub></form><legend id='240q7'></legend><bdo id='240q7'><pre id='240q7'><center id='240q7'></center></pre></bdo></b><th id='240q7'></th></span></q></dt></tr></i><div id='240q7'><tfoot id='240q7'></tfoot><dl id='240q7'><fieldset id='240q7'></fieldset></dl></div>

                    <legend id='240q7'><style id='240q7'><dir id='240q7'><q id='240q7'></q></dir></style></legend>
                      <tbody id='240q7'></tbody>

                      <small id='240q7'></small><noframes id='240q7'>

                            <bdo id='240q7'></bdo><ul id='240q7'></ul>

                          • <tfoot id='240q7'></tfoot>