我正在尝试使用 jquery.validate.unotrusive.js 插件来动态创建表单字段,例如:
var message = $("<textarea id='test'></textarea>");
$(message).attr("data-val", "true")
.attr("data-val-number", "The field CustomerId must be a number.")
.attr("data-val-required", "The CustomerId field is required.");
var span = $('<span class="field-validation-valid" data-valmsg-replace="true"></span>');
$(span).attr("data-valmsg-for", $(message).attr("id"));
var form = $("<form action='url'></form>");
$(form).append(message,span);
我嵌入了 jquery.validate 和 jquery.validate.unobtrusive js 文件,但 textarea 字段在表单提交时未验证。谁能告诉这里出了什么问题?