使用MVC Razor,如何切换客户端验证? [英] Using MVC Razor, how do I toggle client side validation?

查看:104
本文介绍了使用MVC Razor,如何切换客户端验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的Web表单,用户可以在其中提供注册信息,也可以选择匿名进行购买.所以很明显,我需要为一个输入按钮运行验证程序,而不是在单击另一个输入按钮时运行验证程序.

我怀疑我可以使用两个开始和结束表单部分来完成此操作,但是我不希望那样对页面进行布局.对我来说,那也感觉很糟糕.

我是MVC和剃须刀的新手,但是喜欢到目前为止所看到的一切.我只是还不知道如何做一些基本的事情.任何帮助将不胜感激.

I have a very simple web form where a user either provides registration information, or chooses to make a purchase anonymously. So obviously, I need to run validators for one input button and not when the other is clicked.

I suspect that I could do it with two begin and end form sections, but I don''t really like that for the way I want the page to lay out. That also just feels like a bad way to do it to me.

I am a complete newb to MVC and razor, but am liking everything I am seeing so far. I just don''t know how to do some of the basic things yet. Any help would be greatly appreciated.

推荐答案

我需要的细节绝对可以通过两种形式来实现,最简单
@BeginForm(注册",购买"){...


及以后
@BeginForm("Anonymous","Purchase"){....

我仍然希望有人能给我更多有关如何切换验证器的信息.
The specifics of what I need definitely worked easiest by just doing two forms
@BeginForm("Register","Purchase"){...


and later
@BeginForm("Anonymous","Purchase"){....

I still hope that someone can give me more information on how to toggle a validator.


这篇关于使用MVC Razor,如何切换客户端验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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