<!doctype html>
<html>
<head>
<metacharset="utf-8">
<title>脚本之家</title>
<scriptsrc="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
<script>
$(document).ready(function () {
$('#ant').on('keyup mouseout input', function () {
var $this = $(this);
var v = $this.val();
/\S{5}/.test(v) && $this.val(v.replace(/\s/g, '').replace(/(.{4})/g, "$1 "));
});
})
</script>
</head>
<body>
<inputtype="text"id="ant"/>
</body>
</html>
|