【问题标题】:load exteral form into html div and try to on submit with validation but its not working将外部表单加载到 html div 并尝试通过验证提交,但它不起作用
【发布时间】:2014-01-23 21:13:00
【问题描述】:

onclick =id(myModalssid) 用于将 html(external_form_fields.html .formval) 文件特别调用到 div(.modal-body-id) 中。该 div 包含表单,我需要在提交时验证表单。

<script>
    $('#myModalssid').click(function ()
       {
         $('.modal-body-id').load('external_form_fields.html .from_val');
         alert('Message');
       });
</script>

【问题讨论】:

    标签: javascript jquery-ui jquery


    【解决方案1】:

    在 jQuery 中创建函数进行验证,

    并在您的点击事件中调用该函数...

    就像:--

    <script>
        $('#myModalssid').click(function () {
            $('.modal-body-id').load('external_form_fields.html .from_val');
            alert('dgfdfgs');
            formValidation();
        });
        function formValidation()
        {
             //Your validation Process...
        }
    </script>
    

    【讨论】:

    • 我有一个外部 js 脚本。我如何使用它来验证它。
    【解决方案2】:

    表单加载时需要初始化验证脚本:

    $('#myModalssid').click(function ()
       {
         $('.modal-body-id').load('external_form_fields.html .from_val', function() {
             $('.form').on('submit', function() {
                 //your validation script
             });
         });
    
       });
    

    【讨论】:

    • 我有一个外部 js 脚本。我如何使用它来验证它。
    猜你喜欢
    • 2021-08-19
    • 1970-01-01
    • 2014-03-29
    • 1970-01-01
    • 2020-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多