日期:2014-05-16 浏览次数:20351 次
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>test</title>
<script type="text/javascript">
window.onload =function() {
document.getElementById("test").onkeyup =function() {
this.value =this.value.replace(/\s/g,' ').replace(/(\d{4})(?=\d)/g,"$1 ");;
};
};
</script>
</head>
<body>
<input type="text" id="test"/>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>test</title>
<script type="text/javascript">
window.onload =function() {
document.getElementById("test").onkeyup =function() {
this.value =this.value.replace(/\s/g,' ').replace(/([0-9a-zA-Z]{10})(?=\d)/g,"$1 ");;
};
};
</script>
</head>
<body>
<input type="text" id="test"/>
</body>
</html>
window.onload =function() {
document.getElementById("test").onkeyup =function() {
this.value =this.value.replace(/[^0-9a-zA-Z]/g,'').replace(/(.{10})(?=.)/g,"$1,");
};
};