ASP。動態RegEx驗證器

[英]ASP.NET MVC - Dynamic RegEx Validator


In our application our customers are allowed to define a couple of reference fields, and the validation for these reference fields by way of a regular expression. The Validation Regex is saved into our database.

在我們的應用程序中,我們的客戶可以定義兩個引用字段,並通過正則表達式對這些引用字段進行驗證。驗證Regex被保存到我們的數據庫中。

What is the best way to apply this regex as validation for an MVC text box field?

將這個regex應用於MVC文本框字段的驗證的最佳方式是什么?

1 个解决方案

#1


3  

In addition to checking server-side when the value's submitted, you can use remote validation which would create a round-trip to test the current value against logic stored on the server (or in this case in a database).

除了在提交值時檢查服務器端之外,還可以使用遠程驗證,該驗證將創建一個往返,根據服務器上存儲的邏輯(在本例中是數據庫中)測試當前值。

Have a look at the RemoteAttribute and that MSDN article above (which includes an example).

看一下RemoteAttribute和上面的MSDN文章(其中包括一個示例)。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2012/01/09/83a13b4cb5bc73c67b44eb9f36c39874.html



 
  © 2014-2022 ITdaan.com 联系我们: