jQuery html表单不识别活动元素


jQuery html form not identifying the live elements

我有一个html表单,我需要提交到服务器,但在我需要验证表单之前,我有几个动态下拉,需要在表单提交事件上被捕获,但所有其他字段得到验证,循环不识别实时下拉。

我已经尝试在其他循环中捕获活字段,但徒劳。

我以前从来没有遇到过这个问题,我甚至像

jQuery(document).on( "submit", "#adminForm", function(){} );

这是造成这个问题的原因吗?

jQuery("#adminForm").submit(function (event) {
    jQuery("input[type='text'], select, textarea").each(function (i) {
        if (jQuery(this).val() == "") {
            alert("This field is required: " + $(this).attr("name"));
        }
    });
});

这可能会给你一些指导。

jsFiddle: http://jsfiddle.net/4wmjv0re/1/

与jquery的live()一起使用:

jQuery("#adminForm").on( "submit", function(){} );