Hi Team,
I have implimented a custom validation using data annotation on model, MVC 3. Also imlimented jquery and scripts for unobstrusive client validation of the same, taken care to over ride the
public override IEnumerable<ModelClientValidationRule> GetClientValidationRules()as well. but still error message and styling not shown for wrong values.
I checked my scripts and the jquery, they are being registered (placed alerts in them to confirm).
please help.
Server side code below
--DELETED--
--DELETED--
The jquery scripts written for client validation is as below.
--DELETED--
thanks in advance
Anand
5 Answers, 1 is accepted
I can think of a few possible issues that may be causing your troubles:
- jQuery hasn't been added before jquery.validate.
- jQuery and jquery.validate are added but the automatically added scripts by the Telerik ScriptRegistrar method aren't turned off.
- The attribute or the validator isn't registered in the Global.asax file.
All the best,
Daniel
the Telerik team
I have implimented all that you have suggested but it does not work.
i notice the only difference being the version of jquery scripts which is old 1.4.* that you used in the solution provided. attaching my version of scripts.
please help.
Thanks,
Anand
Actually the jQuery version used in the project is 1.6.4(in the _Layout View). The 1.4.4 version is just the one added from the default template.
Another problem with the validation may occur if you are using an earlier version of Internet Explorer with later version of jQuery(1.6.*). If this is the case you should get the latest version(1.9) of the jquery.validate library.
Regards,
Daniel
the Telerik team
#1 >> I do not know why it does not work. Any other thoughts ?
also I have one more query #2 >> , all validations in the Model window do not show if they are in partial view.
i tried adding
jQuery.validator.unobtrusive.parse('EditContactForm'); Sys.Mvc.FormContext._Application_Load();to take care , but does not help. The same works if the model is in main .cshtml page.
To be able to help further, we will need a sample project that reproduces the case. Please send us such sample (or modify the one that Daniel sent you) and we will check it right away.
Georgi Tunev
the Telerik team