달력

072018  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  •  
  •  
  •  
  •  

fn_ParseInt 손봐야함.. 소숫점 안됨.

-------------------------------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">


  <script>
 var digitCheck = function(obj){
  if(!fn_ParseInt(obj.value)){
   alert("숫자만 입력하세요!!");
   var regEx = new RegExp('[^\\-\\+\\.\\d]','g');
   document.getElementById(obj.id).value = obj.value.replace(regEx, '');
  }
 }

 var fn_ParseInt = function(arg1){       
  if(fn_Trim(arg1).length == 0){
   return false;
  }

  var reg = /(^\d+$)|(^\d+\.\d+$)/;
      
  if(reg.test(arg1)){
   return true
  }else{
   return false;
  }
 }

 var fn_Trim = function(arg1) {
  return arg1.replace(/(^\s*)|(\s*$)/gi, "");
 }

  </script>
 </HEAD>

 <BODY>
  <form>
  <input type="text" id="digitTxt" onkeyup="digitCheck(this);" />
  <br />
  </form>

 </BODY>
</HTML>

Posted by Tornado tornado