如何使用Javascript或jQuery检查Html.EditorFor
元素的值是否已更改?
@Html.EditorFor(model => model.AddressPhysical1, new { htmlAttributes = new { @class = "form-control", id = "AddrPhys1", @onload = "TrackChanges(this.value)" } })
$(document).ready(function TrackChanges() {
var address = $('#AddressPhysical1').val();
$('#AddressPhysical1').keyup(function() {
if ($('#AddressPhysical1').val() != content) {
content = $('#AddressPhysical1').val();
alert('Content has been changed');
}
});
});