@Html.TextBoxFor(m => m.TruckTrailerTag, new { @id = "idTruckTrailerTag", @style = "height: 20px; min-height: 20px; border:1px solid #aaaaaa; color: #414040;", @onchange = "onchangeevent();" })
var _isAnyFieldChanged = false;
function onchangeevent(){
alert("12");
_isAnyFieldChanged = true;
}
function confirmExit()
{
return "All changes made will be lost." + _isAnyFieldChanged;
}
window.onbeforeunload = confirmExit;
Hello. I dont have any alert, and the variable always is false when i hit F5.
But its true when i click submit button, and alert also comes. Why ?
Onchange triggers only when submit ?
How then i can check text changed in runtime ?
I need to set that variable to warn user about unsaved changes
Submit redirects to this page