简体   繁体   English

用jquery validate以外的其他框架替换mvc客户端验证

[英]Replace mvc client-side validation with other framework than jquery validate

I want to know if and how it is possible to use an other client-side validation framework (than jquery validate, eg. Parsley) in asp.net mvc? 我想知道是否以及如何在asp.net mvc中使用其他客户端验证框架(而不是jquery验证,例如Parsley)?

I just looked into the mvc sourcecode and it seems to be hard-wired. 我只是查看了mvc源代码,它似乎是硬连接。 This class creates the attributes, which will be added to the control later. 这个创建的属性,这将在后面添加到控制。

Maybe there is a way to inherit from a class and configure it somehow to be used as default. 也许有一种方法可以从类继承并以某种方式配置它以用作默认值。 It seems that asp.net mvc have too many static classes (eg HtmlHelper) which makes it nearly impossible to extend some functionality without rewriting a lot of framework-code? 似乎asp.net mvc有太多的静态类(例如HtmlHelper),这使得几乎不可能在不重写许多框架代码的情况下扩展某些功能吗?

The power of common data annotations is cool to descibe meta information about the data. 通用数据注释的功能很酷,可以描述有关数据的元信息。 It's used by Entity Framework and MVC, but the client-side validation should be limited to jquery validate? 它由Entity Framework和MVC使用,但客户端验证应限于jquery validate?

I know, that I can configure client-validation frameworks like parsley to get used with an other prefix like the "data-val-" (of jquery validate) instead of "data-parsley-", but not all features can be used this way and conflicts are possible. 我知道,我可以配置诸如parsley之类的客户端验证框架,以与其他前缀(如“ jquery validate”的“ data-val-”)代替“ data-parsley-”一起使用,但并非所有功能都可以使用方式和冲突都是可能的。

Hope anyone have an answer for me ;-) 希望有人对我有答案;-)

You can use any client side validation you want to use. 您可以使用要使用的任何客户端验证。 Asp.net provides server code that is translated into client code but that's not the only option. Asp.net提供了转换为客户端代码的服务器代码,但这不是唯一的选择。 You can use any client side code you want independent of the server code framework. 您可以独立于服务器代码框架使用任何想要的客户端代码。 Just include the appropriate client side code on the pages you wish and it'll work. 只要在您希望的页面上包含适当的客户端代码,它就会起作用。

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

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