This is a migrated thread and some comments may be shown as answers.

[Solved] custom validation using data annotations in model MVC3 | error messages not shown on client side though properties are added and jquery written

5 Answers 297 Views
Window
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Narayanarao
Top achievements
Rank 1
Narayanarao asked on 27 Dec 2011, 07:44 AM

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--

My model window code is as below
--DELETED--
The jquery scripts written for client validation is as below.
--DELETED--

thanks in advance
Anand

5 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 27 Dec 2011, 04:12 PM
Hi Narayanarao,

I can think of a few possible issues that may be causing your troubles:

  1. jQuery hasn't been added before jquery.validate.
  2. jQuery and jquery.validate are added but the automatically added scripts by the Telerik ScriptRegistrar method aren't turned off.
  3. The attribute or the validator isn't registered in the Global.asax file.
I attached a project that uses the same validator. Let me know if it works for you.

All the best,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Narayanarao
Top achievements
Rank 1
answered on 30 Dec 2011, 06:55 AM
Hi 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
0
Daniel
Telerik team
answered on 30 Dec 2011, 02:22 PM
Hi,

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
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Narayanarao
Top achievements
Rank 1
answered on 02 Jan 2012, 09:01 AM
Hi,

#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.
0
Georgi Tunev
Telerik team
answered on 02 Jan 2012, 02:48 PM
Hi Narayanarao,

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. 

All the best,
Georgi Tunev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Window
Asked by
Narayanarao
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Narayanarao
Top achievements
Rank 1
Georgi Tunev
Telerik team
Share this question
or