ASP.NET MVC 2.0 Custom Client Validation -


I am trying to create a valid user who will make sure that at least 2 items are selected correctly on verifier server side Works the way but the client side code is never executed.

Here is the code:

  Sys.Mvc.ValidatorRegistry.validators ["country"] = function (rule) {var min = rule.ValidationParameters ["min"] ; Return function (value, context) {If (value> = minute) is back true; Return rule Error message; }; };  

And here is the valid code:

  Descent of the public class: Data Annotation Model Delegator & lt; Custom Validation Country Asset & gt; {Private Ent_minimum; Private string _message; Public Contributor (Model Metadata Metadata, Controller Consultant Context, Custom Validation. Country Attribute Attribute): Base (Metadata, Context, Attribute) {_minimum = attribute.Minimum; _message = attribute.ErrorMessage; } Public override IEnumerable & lt; ModelClientValidationRule & gt; GetClientValidationRules () {var Rule = New ModelClientValidationRule () {Error Message / _message, Validation Type = "Country"}; Rule. Validity Parameter. Add ("Minimum", _minimum); Return new [] (rule); }}  

I have also registered the Verification Adapter in the Global .asx file:

  Protected Zero Application_Start () {AreaRegistration.RegisterAllAreas (); RegisterRoutes (RouteTable.Routes); Data Annotation ModelDelivery Provider Registrar (typef (Age-attituded), typef (Edge Vedicator)); DataAnnotationsModelValidatorProvider.RegisterAdapter (typeof (CountryAttribute), typeof (CountryValidator)); }  

I think that the valuer only works with elements that have pricing assets such as text boxes etc.

Update 1:

EnableClientValidation is implemented correctly and all necessary JS files are included in the project. It appears that I need to attach the obel for reference. I will try and post the results.

& lt;% = Html EnabledCLight validity (); % & Gt; should be in your idea from anywhere, also make sure that you reference MicrosoftAjax.js and MicrosoftMvcValidation.js in the same view (before your JS function) .


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -