How do I extend ASP.NET MVC2 out-of-box validation to validate creditcard / emails? -


I am looking at the file MicrosoftMvcJQueryValidation.js which can be found on your page and ASP.NET MVC2 jquery.validate object in beta

This will allow any verification rule and additional special handling, strings, range and required fields for regulation. If this is a normal / unknown rule type, then it will pass only through such criteria:

  default: __MVC_ApplyValidator_ unknown (rules obje, this rule. Verification type, thisRule.ValidationParameters) ; break; Although  

However, I can not seem to know how to inject additional rules in JSON which is generated by the framework, such as 'email' generally rules only [ Essential] .

I know there are a lot of extensibility points to change the entire verification metadata provider - but I see a simple way.

For example, how can I use 'email' or 'credit card' assumptions in conjunction with a simple model like this:

Public class logs These details {educate the public at the receiving edges} Set; }

  [Required (Error Message = "Please Enter Your Email")] Public String Username {get; Set; } [Required (Error Message = "Please enter your password")] Public string password {get; Set; }}  

You can keep required messages for different types of data, but this Apart from their different features, email and credit car will probably work best for them. [Required (Error Message = "Please Enter Your Email")] [Regular Expression (@ "\ b [A-Z0-9 _% + -] + @ [A- Z0-9 .-] + \. [Es] {2,4} \ b ", error message =" Please enter a valid email address. ")] Public String Email {get; Set; } [Required (error message = "Please enter your password")] [Regular expression ("" (?: 4 [0- 9] {12} (?: [0- 9] {3})? 5 [1- 5] [0-9] {14} | 6 (: 011 | 5 [0-9] [0-9]) [0-9] {12} | 3 [47] [0-9] {13} | 3: | [0-9] {11} (0 [0-5] [68] [0-9]?) | (| 2131 | 1800 | 35 \ d {3}) \ d {11}) $ "Error message =" Please enter a valid credit card. ")] Public string credit card {get; set;}

For more information, refer to the link.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -