更新された完全なコードは次のとおりです
CSS
.validation-error
{
border: 1px solid #ff0000;
background-color: #ffeeee;
}
$.ajax を使用してログインを確認する Jquery コード
$(function () {
$('#btnLogin').click(function (e) {
var email = $('#Email').val(); // this your username textbox value
var password = $('#Password').val(); // this is your password textbox value
var postdata =
{
"Email": email,
"Password": password
};
$.ajax({
tyep: 'POST',
url: '@Url.Action("LogIN","Account")', // your controller action will be called to check for the login details
data: postdata, // this data you have to post to controller for validation
success: function(value) { // if ajax call complete, controller action will return boll value true here
if(valeu) {
$('#divLoginError').addClass("validation-error"); // this will add class class to your textboxes with red broder
$('divLoginError').html('Please check your username / password');
}
},
error: function(errorData) // if any error while calling Ajax. this method is gonna call
{
$('#divLoginError').show().html(errorData);
}
});
});
});