validation.js
1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var Email={
checkEmail:function(self){
var email=document.getElementById('eValidation').value;
var regExp = /^[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_.]?[0-9a-zA-Z])*.[a-zA-Z]{2,3}$/i;
if(regExp.test(email)){
return true;
}else if(email===""){
focusFunction("#eValidation");
alert("이메일을 입력해주세요!");
return false;
}
else {
alert("이메일 형식을 제대로 입력해주세요!");
return false;
}
}
}
var Password={
checkPassword:function(self){
var fpassword=document.getElementById('fValidation').value;
var spassword= document.getElementById('sValidation').value;
if(fpassword==="" || spassword===""){
alert("비밀번호를 입력해주세요!");
return false;
}else if(fpassword===spassword){
return true;
}else{
alert("입력하신 비밀번호들이 다릅니다!");
return false;
}
}
}
function checkValidation(self){
if(Email.checkEmail() && Password.checkPassword() ){
return true;
}else return false;
}
$('#eValidation').keyup(function () {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (re.test($(this).val())) {
$(this).css("borderColor", "green");
} else {
$(this).css("borderColor", "red");
}
});
});