KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I could not seem get client side validation work with the following partial view. This view is inside divTSettings div in the parent view. Tried lots of things from stackoverflow and other sites, nothing seems to work. Any ideas? <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script> @using (Ajax.BeginForm("CreateT", "TAdmin", null, new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "divTSettings"}, new { id = "CreateTForm" })) { <div> <label>Name:</label> <input type="text" name="tName" id="tName"/> @Html.ValidationMessage("tName") <input type="submit" value="Submit"/> </div> } <script type="text/javascript"> $(function() { $('#CreateTForm').validate({ rules: { tName: { required: true } }, messages: { tName: { required: 'Name required' } } }); $("#CreateTForm").removeData("validator"); $("#CreateTForm").removeData("unobtrusiveValidation"); $.validator.unobtrusive.parse("#CreateTForm"); }); </script>
Tags (comma-separated)
Save Edits
Cancel