check.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // 숫자 가능
  2. $(document).on('keyup', '.fnNumeric', function(e) {
  3. if(e.keyCode == 8 || e.keyCode == 9 || e.keyCode == 37 || e.keyCode == 39 || e.keyCode == 46 ) return;
  4. re = /[^0-9]/gi;
  5. if(re.test($(this).val())) $(this).val($(this).val().replace(re,""));
  6. });
  7. // 숫자 + . 가능
  8. $(document).on('keyup', '.fnNumericDot', function(e) {
  9. if(e.keyCode == 8 || e.keyCode == 9 || e.keyCode == 37 || e.keyCode == 39 || e.keyCode == 46 ) return;
  10. re = /[^.0-9]/gi;
  11. if(re.test($(this).val())) $(this).val($(this).val().replace(re,""));
  12. });
  13. // 특수문자 제거 개요 : 입력받은 String을 정규식(match)에 맞는 규칙으로 replaceAll 후 String 반환한다. 입력값 : string
  14. function itp_fn_remove_special_char(str) {
  15. var match = /[^\u3131-\u314e\u314f-\u3163\u2E80-\u2EFF\u3040-\u309F?\u30A0-\u30FF\u30F0-\u31FF\u3200-\u32FF\u3400-\u4DBF\u4E00-\u9FFF\uAC00-\uD7A3xfe0-9a-zA-Z\\+\\&\\%\\.\\_\\(\\)\\/\\s\ \u007E]/gi;
  16. str = str.replace(match, "");
  17. str = str.replace(/[\r\n]/gi, "");
  18. str = str.replace(/\t/gi, " ");
  19. return str;
  20. }
  21. // 문자 유니코드를 이용한 Byte 길이 구하기
  22. function itp_fn_get_byte_length(s,b,i,c){
  23. for(b=i=0;c=s.charCodeAt(i++);b+=c>>11?3:c>>7?2:1);
  24. return b;
  25. }
  26. // 사업자번호 입력
  27. $(document).on('keyup', '.fnBizNo', function(e) {
  28. $(this).val( $(this).val().replace(/[^0-9]/g, "").replace(/([0-9]{3}|[0-9]{2})([0-9]+)?([0-9]{5})$/,"$1-$2-$3").replace("--", "-") );
  29. });
  30. // 휴대폰번호 입력
  31. $(document).on('keyup', '.fnCellNo', function(e) {
  32. $(this).val( $(this).val().replace(/[^0-9]/g, "").replace(/(^02|^0505|^1[0-9]{3}|^0[0-9]{2})([0-9]+)?([0-9]{4})$/,"$1-$2-$3").replace("--", "-") );
  33. });
  34. // 주민번호,법인번호 입력
  35. $(document).on('keyup', '.fnJuminNo', function(e) {
  36. if($(this).val().length > 6) {
  37. $(this).val( $(this).val().replace(/[^0-9]/g, "").replace(/([0-9]{6})?([0-9]+)$/,"$1-$2").replace("--", "-") );
  38. }
  39. });