$("#updateBtn").click(function(){
//검증
$(".screenid").each(function(index){
if($(".screenid:eq("+index+")").val()==""){
alert("화면 아이디를 모두 입력해주세요.");
$(".screenid:eq("+index+")").focus();
return;
}
});
});
$("#detailCreateFrm").submit();
위의 예제를 보면
JQeury의 each반복문을 이용하여 검증하고 있다. 이때 if 문으로 검증하고 return; 을 해줬을 경우 검증 자체를 빠져나올 줄 알았지만
반복문만 빠져나올 뿐 아래로 계속 프로그램을 실행하더라..
결국 submit을 만나고야 마는데..
아래와 같이 해결해 주었다.
$("#updateBtn").click(function(){
var b=false;
//검증
$(".screenid").each(function(index){
if($(".screenid:eq("+index+")").val()==""){
alert("화면 아이디를 모두 입력해주세요.");
$(".screenid:eq("+index+")").focus();
b = true;
}
});
if(b) return;
});
$("#detailCreateFrm").submit();
'에러' 카테고리의 다른 글
java.util.NoSuchElementException: No line found (2) | 2014.05.08 |
---|---|
maven 에러 (0) | 2014.05.01 |
전역변수 사용시 주의점 (0) | 2014.04.23 |
ResultSet 에러 전방향 전용 결과 집합에 부적합한 작업이 수행되었습니다 (0) | 2014.04.09 |
자바스크립트의 name으로 핸들링 하려할 때 주의 할점 (0) | 2014.03.31 |