当前位置: 代码迷 >> Web前端 >> 禁止输入非金额数目字
  详细解决方案

禁止输入非金额数目字

热度:67   发布时间:2013-04-07 12:50:11.0
禁止输入非金额数字

<html>?
?
<head>?
?
<title>禁止输入非金额数字</title>?
?
<script type="text/javascript">?
?
function CheckInputInt(oInput) {
?? var obj = oInput.value;
?? var length = obj.length;
?? var objStart = obj.substr(0,1);
?? var objSub = obj.substr(1,1);
?? var objVal = obj.substr(1,length);
?? if ('' != objStart.replace(/\d/g,''))??
?? {
????? if(objStart != '-'){
??????? objStart = objStart.replace(/\D/g,'');
????? }else{
?????????? if(objSub == '0'){
???????????? objVal = '';
?????????? }
????? }??
?? }
?? if ('' != objVal.replace(/\d/g,'')){
???????????
????????? objVal = objVal.replace(/\D/g,'');??
??? }else{
?????? if(objStart == 0)
????????????? objVal = '';
??? }???
?? oInput.value = objStart+objVal;
?}?
?
</script>?
?
</head>?
?
<body>?
?
禁止输入非金额数字<input? type="text" name="num" onkeyup="CheckInputInt(this);" onblur="CheckInputInt(this);" onafterpaste="CheckInputInt(this);" />?
?
</body>?
?
</html>

  相关解决方案