Formvalidation addField 不执行任何操作

Formvalidation addField doesn't do anything

我正在使用 formvalidation.io to validate a form in Bootstrap. The form has a dynamic field option, so I am trying to use the addField functionality to make sure that this field is included when the form is validated. As explained here。不幸的是,这不起作用。新字段永远不会包含在验证中。

添加新按钮的脚本:

$(document).on("click", '#add-row', function() {
   var rownr = parseInt($(this).attr("data-rownr"));
   rownr = (rownr+1).toString();
   $(this).attr("data-rownr", rownr);
   var rowid = '#contact-rule-'+rownr;
   $(this).before("<input type='text' id='"+rowid+"' name='"+rowid+"'/></div>");
   $option = $(document).find(rowid);
   $('#ruleForm').formValidation('addField', $option);
});

通过预先在代码中添加所有字段然后隐藏并使用 javascript 使它们再次可见来解决此问题。同时设置 Formvalidation 以排除隐藏字段。