JS代碼:
var str_old = "";
var str_new = "";
var timerID;
var flag = true;
function ck(obj) {
alert(document.getElementById(obj).value);
}
function vv(obj) {
setInterval(function () { ck(obj); });
}
function check(obj) {
if (flag) {
str_old = document.getElementById(obj).value;
if (str_old != str_new) {
str_new = str_old;
str_old = document.getElementById(obj).value;
}
else {
document.getElementById(obj).value = "";
}
}
}
function txtFocus(obj) {
if (document.getElementById(obj).value != "") {
flag = false;
}
else {
flag = true;
}
timerID = setInterval(function () { check(obj); }, 35);
}
function txtChanged() {
flag = true;
}
function txtBlur() {
clearInterval(timerID);
}
function txtLeave(obj) {
if (event.keyCode == 13) {
obj.blur();
clearInterval(timerID);
}
}
後臺代碼:
this.txtFacilityID.Attributes.Add("onKeyPress", "txtLeave(this)");
this.txtFacilityID.Attributes.Add("onfocus", "txtFocus(‘txtFacilityID‘)");
this.txtFacilityID.Attributes.Add("onblur", "txtBlur()");
this.txtFacilityID.Attributes.Add("onpropertychange", "txtChanged()");