회원정보 입력폼 정규표현식
카테고리 없음 2011. 1. 17. 13:19반응형
프로젝트중 필요해서 써본것.
private function validate($type:String, $str:String):Boolean {
var regExp:RegExp;
var isTrue:Boolean
switch($type) {
case "email" :
regExp = /([0-9a-zA-Z_-]+)@([0-9a-zA-Z_-]+)\.([0-9a-zA-Z_-]+)/;
break;
case "name" :
regExp = /[\uac00-\ud7a3]{2,4}/;
break;
case "tel" :
regExp = /^[0-9]{2,3}-[0-9]{3,4}-[0-9]{3,4}$/;
break;
case "post":
regExp = /^\d{3}-?\d{3}$/;
break;
case "birth":
regExp = /^[0-9]/;
break;
}
isTrue = regExp.test($str);
return isTrue;
private function validate($type:String, $str:String):Boolean {
var regExp:RegExp;
var isTrue:Boolean
switch($type) {
case "email" :
regExp = /([0-9a-zA-Z_-]+)@([0-9a-zA-Z_-]+)\.([0-9a-zA-Z_-]+)/;
break;
case "name" :
regExp = /[\uac00-\ud7a3]{2,4}/;
break;
case "tel" :
regExp = /^[0-9]{2,3}-[0-9]{3,4}-[0-9]{3,4}$/;
break;
case "post":
regExp = /^\d{3}-?\d{3}$/;
break;
case "birth":
regExp = /^[0-9]/;
break;
}
isTrue = regExp.test($str);
return isTrue;
}
반응형