input-validation-error issue unobtrusive client validation

pali

New Member
Issue with Unobtrusive client validation unit tesing .I am working on Unit testing the javascript client validation methods using QUNIT.For method "Requiredif"Here is the model class :\[code\] public class EqualToTrue { [Required] public bool Value1 { get; set; } [RequiredIf("Value1", true)] public string Value2 { get; set; } }\[/code\]Basically Here the content of cshtml file \[code\] <body> <h1 id="qunit-header">QUnit example</h1> <h2 id="qunit-banner"></h2> <h2 id="qunit-userAgent"></h2> <ol id="qunit-tests"></ol> <div> @using (Html.BeginForm(null,null,FormMethod.Post,new {id = "myform"})) { @Html.ValidationSummary(true); <div> @Html.CheckBoxFor(m => m.RequiredTests.EqualToTrue_IsTrueHasValue.Value1) @Html.EditorFor(m => m.RequiredTests.EqualToTrue_IsTrueHasValue.Value2) @Html.ValidationMessageFor(m => m.RequiredTests.EqualToTrue_IsTrueHasValue.Value2) </div> } </div> <input type="submit" id="btn_validation"/>\[/code\]On btn_validation,the form gets validated and error messages are displayed properly.The issue is "input-validation-error" css is not getting added to textbox.The resulting cshmtl content is here\[code\] <div> <input checked="checked" data-val="true" data-val-required="The Value1 field is required." id="RequiredTests_EqualToTrue_IsTrueHasValue_Value1" name="RequiredTests.EqualToTrue_IsTrueHasValue.Value1" type="checkbox" value="http://stackoverflow.com/questions/15876679/true" /><input name="RequiredTests.EqualToTrue_IsTrueHasValue.Value1" type="hidden" value="http://stackoverflow.com/questions/15876679/false" /> <input class="text-box single-line" data-val="true" data-val-requiredif="The field Value2 is required if Value1 is not empty" data-val-requiredif-dependentproperty="RequiredTests_EqualToTrue_IsTrueHasValue_Value1" data-val-requiredif-targetvalue="http://stackoverflow.com/questions/15876679/true" id="RequiredTests_EqualToTrue_IsTrueHasValue_Value2" name="RequiredTests.EqualToTrue_IsTrueHasValue.Value2" type="text" value="http://stackoverflow.com/questions/15876679/hello" /> <span class="field-validation-valid" data-valmsg-for="RequiredTests.EqualToTrue_IsTrueHasValue.Value2" data-valmsg-replace="true"></span> </div>\[/code\]Could anyone tell me where i am going wrong..if there are any validation error,it should add input-validation-error css class.
 
Top