mvc中的验证问题 [英] validation problem in mvc
本文介绍了mvc中的验证问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在MVC 4.0 Razor应用程序中验证表单是否包含验证天气。
因为在我的表单中有50个控件,其中30个控件是必需的。我用数据填充了29个控件,当我点击保存按钮时,它会弹出请输入数据。我怎么办?
how to verify weather the form contains validations or not in MVC 4.0 Razor application.
because in my form 50 controls there, in that 30 controls are mandatory. i filled 29 controls with data, when i click on save button it shows pop up like "Please Enter data". how can i ?
推荐答案
请检查您的课程,因为您可能已经给出了[必需]属性,并且您确认了
if( ModelState.IsValid){
//做好工作
}
else {
// response = error消息/验证消息
}
Please check your class as there you might have given the [Required] attribute and you validate with
if(ModelState.IsValid){
//Do the job
}
else{
//response=error message/validation message
}
这篇关于mvc中的验证问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文