Reputation: 23
I have a textbox and password control in my login page, below is my view,
@Html.TextBoxFor(m => m.Login)
@Html.PasswordFor(m => m.Password)
I have written jquery to validation the above 2 fields,
$('#txtLogin').blur(function () {
if ($('#txtLogin').val() == '') {
$('#LoginError').html("Please enter email address.");
return false;
} else {
return true;
}
});
$('#txtPassword').blur(function () {
if ($('#txtPassword').val() == '') {
$('#LoginError').html("Please enter password.");
return false;
} else {
return true;
}
});
I am wondering why this is not only working in IE9? it works perfectly in IE10 and safari 5.1
Upvotes: 1
Views: 199
Reputation: 979
In MVC 1st thing you need ensure to put below line in web.config
<add key="UnobtrusiveJavasScriptEnable" value="true"/>
Then add jquery unobstrusive library to your model, especially in MVC try to have jquery in separate file and refer the file into view.
it is not enough to add only validation jquery library, in mvc add unobstrusive validate library too.
If it is still not working, then try to call jquery onblur function from html control itself like below. I guess this is related to browser issue.
@Html.TextBoxFor(m => m.Login,new {"onblur","txtLogin_onbluur"})
Upvotes: 1