MVC2 中的 SSN 验证
我有一个业务需求,我需要将 SSN 字段显示到三个单独的文本框中,如果其中任何一个文本框为空并且用户单击“保存”,我需要在 SSN 字段顶部显示一条常见错误消息:“SSN是必填字段”。我已在所有这些字段的视图模型上添加了必需的字段属性,因此我收到三条编辑消息,表示需要 SSN。在这种情况下如何仅呈现一项编辑?
我正在使用 ASP.NET MVC 2
我的视图模型是这样的
[Required]
SSN_FirstThreeDigits
[Required]
SSN_SecondTwoDigits
[Required]
SSN_ThirdFourDigits
任何建议
谢谢 苏布
I have a business requirement where in i need to display SSN Field into three separate text boxes and if any one of the textbox is blank and user clicks save, I need to display a common error message on top of the SSN Field saying- "SSN is required field". I have added required field attribute on the view model on all these fields so i am getting three edit messages saying SSN is required. how to present only one edit in this case ?
I am using ASP.NET MVC 2
My view model is like this
[Required]
SSN_FirstThreeDigits
[Required]
SSN_SecondTwoDigits
[Required]
SSN_ThirdFourDigits
Any suggestions
Thanks
Subu
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
SSNValidator.com 现在有一个用于验证社会安全号码的 API。数据元素包括该号码是否已签发、大概的签发日期、签发状态以及是否在死亡索赔中使用。访问该站点并单击 API/批处理链接了解详细信息。
SSNValidator.com now has an API for validating social security numbers. Data elements include whether or not the number was issued, approximate date of issuance, state of issuance and if it was used in a death claim. Go to the site and click the API/Batch Processing links for details.
Mvc.ValidationTookit Alpha 版本:使用 MVC 3 进行条件验证 可以做到这一点。
The Mvc.ValidationTookit Alpha Release: Conditional Validation with MVC 3 can do this.
您可能需要自定义模型活页夹。请查看这篇文章并了解他如何验证出生日期
You may need a custom model binder. Please have a look at this article and see how he validates date of birth