자바스크립트 정규식을 이용한 데이터체크
페이지 정보
작성자 서방님 댓글 0건 조회 156회 작성일 10-03-18 15:31본문
// 빈값 체크
function isEmpty(str)
{
if ( str.match(/^$/) )
return true;
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;
}
댓글목록
등록된 댓글이 없습니다.