简体   繁体   English

没有jQuery的ASP.NET MVC服务器端验证?

[英]ASP.NET MVC Server-side validation without jquery?

Are there any samples of doing remote[?] server-side form validation in ASP.net MVC without javascript or jQuery. 在没有JavaScript或jQuery的ASP.net MVC中,是否有任何进行远程[?]服务器端表单验证的示例。 The validation needs to work after form is posted? 表单发布后验证需要工作吗?

这是Scott Gu的旧博客文章,也许可以帮助您入门: http : //weblogs.asp.net/scottgu/archive/2008/09/02/asp-net-mvc-preview-5-and-form -posting-scenarios.aspx

Why you would do this without jQuery is beyond me considering in mvc 3, even the ajax stuff happens with jQuery behind the scenes. 为什么在没有jQuery的情况下执行此操作,这是我在MVC 3中无法考虑的,即使Ajax发生在jQuery发生在后台的情况下。 Im assuming when you say remote validation you mean client validation but calling to the server. 我假设当您说远程验证时,您的意思是客户端验证,但调用服务器。

In that case you will have to construct a call to your url to validate the parameter - using 'some' client javascript library or plain xmlhttprequest calls. 在这种情况下,您将必须构造对URL的调用以验证参数-使用“某些”客户端JavaScript库或简单的xmlhttprequest调用。 but frankly.. to do this without jQuery when the path of mvc clearly includes jQuery, isn't going to be the best design decision IMHO : ) 但坦率地说..当mvc的路径明显包含jQuery时,要在没有jQuery的情况下执行此操作,这并不是最佳的设计决策恕我直言:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM