87,910
社区成员
发帖
与我相关
我的任务
分享
f.getEl().dom.onkeyup = function(e) {
if (.....) {
if (f.getValue().length < 10) {
window.numid = f.getValue();//window.numid保存原值,用于提交
window.flags = false;
} else {
if (!window.flags) {
window.numid = f.getValue();
}
(function() { f.setValue(f.getValue().substring(0, 10) + "******") }).defer(20);
window.flags = true;
}
} else {
window.numid = f.getValue();
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>filterStr.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript">
String.prototype.replaceAll = function(s1, s2) {
var temp = this;
while (temp.indexOf(s1) != -1) {
temp = temp.replace(s1, s2);
}
return temp;
}
function filter(o) {
var temp = o.value;
var index = temp.lastIndexOf('*');
index = index == -1 ? 0 : index + 1;
var val = temp.substring(index, temp.length);
var filterVal = o.getAttribute("filterValue") == undefined ? "" : o.getAttribute("filterValue");
o.setAttribute("filterValue", filterVal + val);
var ary = temp.split('');
var result = "";
for (var i = 0; i < ary.length; i++) {
if (ary[i] != "*") {
result = temp.replaceAll(ary[i], '*');
}
}
o.value = result;
}
function getVal() {
alert(document.getElementById("s").getAttribute("filterValue"));
}
</script>
</head>
<body>
<input type="text" id="s" onkeyup="filter(this)"/>
<input type="button" value=" get Value " onclick="getVal()">
</body>
</html>