如何对MVC中的集合内的属性进行验证,如model.addvm [add] .licenseattributevalue? [英] How to do validation for properties inside collection in MVC like model.addvm[add].licenseattributevalue?

查看:82
本文介绍了如何对MVC中的集合内的属性进行验证,如model.addvm [add] .licenseattributevalue?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





感谢您帮助推进。



我必须一次保存多个值因为至少应该输入一个值

我希望在一个容器中为所有人显示一条消息。
$ m $ b在mvc视图中名称生成如此AddVm [] .AttributeValue。

i我能够进行验证,但它的生成只有一个消息

应该在一个容器中。



Hi,

Thanks for helping advance.

I have to save multiple values at once in that at least one value should be entered
and i want to show one message for all in a container .
in mvc view the name is generating like this AddVm[].AttributeValue .
i am able to put validation but its generating for all but i want only one message
that should be in one container.

$.each($('.licenseattributevalreq'), function () {
       $(this).rules('add', {
           require_from_group: [1, '.licenseattributevalreq'], messages: { require_from_group :"Please fill atlease one Attribute Value."}
       });
   });
   if ($('.licenseattributevalreq').valid() == false) {return false; };



工作正常



我尝试过:



$ .each($('。licenseattributevalreq'),function(){

$(this).rules('add' ,{

require_from_group:[1,'。licenseattributevalreq'],消息:{require_from_group:请填写一个属性值。}

});

});

if($('。licenseattributevalreq')。valid()== false){return false; };


its working properly

What I have tried:

$.each($('.licenseattributevalreq'), function () {
$(this).rules('add', {
require_from_group: [1, '.licenseattributevalreq'], messages: { require_from_group :"Please fill atlease one Attribute Value."}
});
});
if ($('.licenseattributevalreq').valid() == false) {return false; };

推荐答案

.each(


('。licenseattributevalreq'),function(){
('.licenseattributevalreq'), function () {


(this).rules('add', {
require_from_group:[1,'。licenseattributevalreq'],消息:{require_from_group:请填写一个属性值。}
});
});
if(
(this).rules('add', { require_from_group: [1, '.licenseattributevalreq'], messages: { require_from_group :"Please fill atlease one Attribute Value."} }); }); if (


这篇关于如何对MVC中的集合内的属性进行验证,如model.addvm [add] .licenseattributevalue?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆