// 限制文本框输入保留2位精度的小数
$("input[name='money']").live("keyup paste",function(){
var reg = $(this).val().match(/\d+\.?\d{0,2}/);
var txt = '';
if (reg != null) {
txt = reg[0];
}
$(this).val(txt);
}).live("change",function () {
$(this).keypress();
var v = $(this).val();
if (/\.$/.test(v))
{
$(this).val(v.substr(0, v.length - 1));
}
});
// 限制文本框只能输入正整数
$("#deptCode").live("keyup paste change",function(event){
var reg = $(this).val().match(/[1-9][0-9]*/);
var txt = '';
if (reg != null) {
txt = reg[0];
}
$(this).val(txt);
});
// 清空两端的空格,类似java trim()方法
var str = " abc ".replace(/(^\s*)|(\s*$)/g,'');