//整数 function mustbeInteger(ele) { var e = $(ele); e.on('keyup', function() { var v = $(this).val(); if (v.length === 1) { $(this).val(v.replace(/[^1-9]/g, '')); } else { $(this).val(v.replace(/\D/g, '')); } }).on('afterpaste', function() { var v = $(this).val(); if (v.length === 1) { $(this).val(v.replace(/[^1-9]/g, '')); } else { $(this).val(v.replace(/\D/g, '')); } }); } //浮点数 function mustbeFloat(ele) { var e = $(ele); e.on('keyup', function() { var v = $(this).val(); if (v.length === 1) { $(this).val(v.replace(/[^0-9]/g, '')); } else { $(this).val(v.replace(/[^0-9\.]/g, '')); } }).on('afterpaste', function() { if (v.length === 1) { $(this).val(v.replace(/[^0-9]/g, '')); } else { $(this).val(v.replace(/[^0-9\.]/g, '')); } }); } //整数值 function intval(e, d) { d = d || 0; var ele = $(e); if (ele.val() === "") { return d; } try { var num = parseInt(ele.val()); if (isNaN(num)) return d; return num; } catch (e) { return d; }}/*** 常用JS验证 ***/function isBankCard(s) { var patrn = /^[0-9]{16,19}$/; if (!patrn.exec(s)) return false; return true;}function isDigit(s) { var patrn = /^[0-9]{1,20}$/; if (!patrn.exec(s)) return false; return true;}function isFloat(s) { if (s === "0") return true; var patrn = /^(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*))$/; if (!patrn.exec(s)) return false; return true;}function isEmail(s) { var patrn = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/; if (!patrn.exec(s)) return false; return true;}function isMobile(str) { return str.length === 11 && /^1+\d{10}$/.test(str);}function isDate(str) { var re = /^(\d{4})-(\d{2})-(\d{2})$/; return re.test(str);}function checkChinese(str) { var re = /^[\u4E00-\u9FA5\uF900-\uFA2D]+$/; return re.test(str);};function isChineseName(v) { if (v == '') return false; if (v.length < 2) { return false; } var name = v.replace(/·/g, ''); name = name.replace(/?/g, ''); return checkChinese(name);};