p

자바스크립트 이메일 체크 함수

function _check_email(email) {
var pattern = /^(.+)@(.+)$/;
var atom = "\[^\\s\\(\\)<>#@,;:!\\\\\\\"\\.\\[\\]\]+";
var word="(" + atom + "|(\"[^\"]*\"))";
var user_pattern = new RegExp("^" + word + "(\\." + word + ")*$");
var ip_pattern = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var domain_pattern = new RegExp("^" + atom + "(\\." + atom +")*$");

var arr = email.match(pattern);
if (!arr) return "Email address seems incorrect (check @ and .'s)";
if (!arr[1].match(user_pattern)) return "The username doesn't seem to be valid.";

var ip = arr[2].match(ip_pattern);
if (ip) {
for (var i=1; i<5; i++) if (ip[i] > 255) return "Destination IP address is invalid!";
}
else {
if (!arr[2].match(domain_pattern)) return "The domain name doesn't seem to be valid.";
var domain = arr[2].match(new RegExp(atom,"g"));
if (domain.length<2) return "This address is missing a hostname!";
if (domain[domain.length-1].length<2 || domain[domain.length-1].length>3)
return "The address must end in a three-letter domain, or two letter country.";
}
return false;
}<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 16:57:14 JavaScript에서 이동 됨]</div>
|
댓글을 작성하시려면 로그인이 필요합니다. 로그인

팁게시판

디자인과 관련된 유용한 정보를 공유하세요. 질문은 상단의 QA에서 해주시기 바랍니다.

+
제목 글쓴이 날짜 조회
19년 전 조회 2,727
19년 전 조회 2,974
19년 전 조회 2,180
19년 전 조회 2,206
19년 전 조회 1,985
19년 전 조회 3,264
19년 전 조회 2,095
19년 전 조회 2,767
19년 전 조회 1,726
19년 전 조회 5,300
19년 전 조회 3,545
19년 전 조회 4,292
19년 전 조회 3,038
19년 전 조회 2,504
19년 전 조회 3,911
19년 전 조회 2,632
19년 전 조회 2,969
19년 전 조회 2,937
19년 전 조회 4,159
19년 전 조회 3,106
19년 전 조회 3,006
19년 전 조회 3,662
19년 전 조회 2,958
19년 전 조회 2,179
19년 전 조회 2,208
🐛 버그신고