Good Day,
Getting the same error message in a span on
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
Even If I use or not using the below code
https://johnnyreilly.github.io/jQuery.Validation.Unobtrusive.Native/AdvancedDemo/Tooltip.html
Why tool tip is not displayed.
I suspect the jquery, bootstrap and jquer.validate versions that I am using
https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.17.0/jquery.validate.js
Bootstrap css - 2.3.1
@model StudentMaintanance.Models.StudentViewModel
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<style type="text/css">
body {
font-family: Arial;
font-size: 10pt;
}
.error {
color: red;
}
</style>
</head>
<body>
@using (@Html.BeginForm("Contact", "Home", FormMethod.Post))
{
<table>
<tr>
<td>@Html.DisplayFor(m => m.StudentName)</td>
<td>@Html.TextBoxFor(m => m.StudentName)</td>
<td>@Html.ValidationMessageFor(m => m.StudentName, "", new { @class = "error" })</td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit" /></td>
<td></td>
</tr>
</table>
}
</body>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
</html>
<script type="text/javascript">
$("form").validate({
showErrors: function(errorMap, errorList) {
// Clean up any tooltips for valid elements
$.each(this.validElements(), function (index, element) {
var $element = $(element);
$element.data("title", "") // Clear the title - there is no error associated anymore
.removeClass("error")
.tooltip("destroy");
});
// Create new tooltips for invalid elements
$.each(errorList, function (index, error) {
var $element = $(error.element);
$element.tooltip("destroy") // Destroy any pre-existing tooltip so we can repopulate with new tooltip content
.data("title", error.message)
.addClass("error")
.tooltip(); // Create a new tooltip based on the error messsage we just set in the title
});
},
submitHandler: function(form) {
alert("This is a valid form!");
}
});
</script>
As you can see I have included the script from the above link
after pasting the script from the above link I am receiving just the alert("This is a valid form!");
Thanks,
R