본문 바로가기
  • 행복하게 오래오래 개발자로 살아가기
FrontEnd

URL 체크

by yundev 2013. 9. 3.
반응형
function validateURL(textval) {
   var urlregex = new RegExp( "^(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$");
  return urlregex.test(textval);
}

참고 : http://jsfiddle.net/rDT4L/
반응형

'FrontEnd' 카테고리의 다른 글

자바스크립트 , 추천  (0) 2013.09.16
Image Sprite / Image Replacement  (0) 2013.09.03
[JS] location.href / location.replace 차이점  (0) 2013.09.03
form의 enctype 속성, file 전송  (0) 2013.09.03
HTML의 책갈피 기능  (0) 2013.09.03