問題:
I am using the jQuery validation plugin .我正在使用jQuery驗證插件。 Great stuff!好東西! I want to migrate my existing ASP.NET solution to use jQuery instead of the ASP.NET validators.我想遷移我現有的 ASP.NET 解決方案以使用 jQuery 而不是 ASP.NET 驗證器。 I am missing a replacement for the regular expression validator.我缺少正則表達式驗證器的替代品。 I want to be able to do something like this:我希望能夠做這樣的事情:
$("Textbox").rules("add", { regularExpression: "^[a-zA-Z'.\s]{1,40}$" })
How do I add a custom rule to achieve this?如何添加自定義規則來實現這一點?
解決方案:
參考一: https://stackoom.com/question/1B2N參考二: jQuery validate: How to add a rule for regular expression validation?