자바스크립트 정규식을 이용한 데이터체크 > script

본문 바로가기
사이트 내 전체검색

script

자바스크립트 정규식을 이용한 데이터체크

페이지 정보

작성자 서방님 댓글 0건 조회 156회 작성일 10-03-18 15:31

본문

// 빈값 체크
function isEmpty(str)
{
 if ( str.match(/^$/) )
  return true;

 return false;
}

// 영문만 입력 체크
function onlyAlpha(str)
{
 var findStr = str.match(/[a-z]+/i);

 if ( str == findStr )
  return true;
 else
  return false;
}

// 숫자만 입력 체크
function onlyNumeric(str)
{
 var findStr = str.match(/[0-9]+/);

 if ( str == findStr )
  return true;
 else
  return false;
}

// 한글만 입력 체크
function onlyKorean(str)
{
 var findStr = str.match(/[가-힣ㄱ-ㅣ]+/);

 if ( str == findStr )
  return true;
 else
  return false;
}

// 이메일 입력 체크
function isEmail(str)
{
 var findStr = str.match(/[\w]+@[\w.]+\.[a-zA-Z]+/);

 if ( str == findStr )
  return true;
 else
  return false;
}

// 주소형식 체크
function isURL(str)
{
 var findStr = str.match(/https?:\/\/[\w+.]+[a-z]{2,}/);

 if ( str == findStr )
  return true;
 else
  return false;
}

댓글목록

등록된 댓글이 없습니다.

Total 846건 16 페이지
게시물 검색

회원로그인

접속자집계

오늘
117
어제
225
최대
1,347
전체
154,876
Latest Crypto Fear & Greed Index

그누보드5
Copyright © 서방님.kr All rights reserved.