반응형

참고: http://blog.naver.com/PostView.nhn?blogId=agapeuni&logNo=60114548468&parentCategoryNo=375&viewDate=&currentPage=1&listtype=0

http://stackoverflow.com/questions/11440128/jquery-check-if-checkbox-is-not-checked

 

http://lng1982.tistory.com/80

 

//전체선택

function fn_checkAll() {

if($("#psninfAgrYn").val() == "Y") {

$("input[name=psninfAgrYnSub]:checkbox").each(function(){

$(this).attr("checked", false);

});

$("#psninfAgrYn").val("");

$("#psninfAgrYn").attr("checked", false);

} else {

$("input[name=psninfAgrYnSub]:checkbox").each(function(){

$(this).attr("checked", true);

});

$("#psninfAgrYn").val("Y");

$("#psninfAgrYn").attr("checked", true);

 

}

}

 

//선택확인

function fn_checkCnt() {

var chkSubCnt = $("input[name=psninfAgrYnSub]").length;

var chkSubCntChecked = $("input[name=psninfAgrYnSub]:checked").length;

 

if(chkSubCnt == chkSubCntChecked) {

$("#psninfAgrYn").val("Y");

$("#psninfAgrYn").attr("checked", true);

} else {

$("#psninfAgrYn").val("");

$("#psninfAgrYn").attr("checked", false);

 

}

}

 

//화면구성

<form:checkbox path="psninfAgrYn" id="psninfAgrYn" value="" onclick="fn_checkAll();/>전체선택

<input type="checkbox" name="psninfAgrYnSub" onclick="fn_checkCnt(); />개인정보 항목에 동의

<input type="checkbox" name="psninfAgrYnSub" onclick="fn_checkCnt(); />이용목적 항목에 동의

<input type="checkbox" name="psninfAgrYnSub" onclick="fn_checkCnt(); />이용기간 항목에 동의

 

 

반응형
반응형

출처: http://blog.naver.com/PostView.nhn?blogId=chocolleto&logNo=30086937115&categoryNo=29&viewDate=&currentPage=1&listtype=0

http://jeevanpatil.wordpress.com/2011/07/22/prevention_of_xss/

http://forum.spring.io/forum/spring-projects/web/106627-spring-3-mvc-annotation-portlet-form-form-submission-nohandlerfoundexception

 

spring mvc form 태그를 사용하면서 xss(cross site scripting)을 처리하고자

< -> &lt;

> -> &gt;

' -> &apos;

"-> &quote;

 

로 변환해서 데이터베이스에 저장하였다.

 

그렇게 처리하니 spring form 태그에서는 & -> &amp;로 변환해서 화면에 보여주게 되었고

화면에는 <script가 &lt;script로 보여지게 된것이다.

 

이유는 &가 html태그로 치환되어 표현하기 때문이다.

그렇기에 <form:input path="name" htmlEscape="false" />로 처리하니

화면에 <script로 보여지게 되었다.

 

defaultHtmlEscape는 true로 되어있기 때문에 spring form mvc에서는

false로 지정해 주어야 한다.

 

(근데 궁금한것은 어디서는 web.xml에 defaultHtmlEscape가 true라고 하고, 어디서는 false라고 하는데

어떤것이 진실인지 찾아봐야겠다.)

 

 

To avoid XSS security threat in spring application jeevanpatil.mht

 

반응형
반응형

출처: http://stackoverflow.com/questions/14784705/dynamically-changing-a-jquery-validate-rule-when-a-checkbox-is-checked

http://stackoverflow.com/questions/11023499/jquery-validation-adding-removing-rules-dynamically-based-on-dropdown-selectio

 

validation 규칙을 동적으로 부여하고 싶을 때 사용

구현하고자 하는 것은 데이터베이스에 저장된 비밀번호와 같은 값이면 validation규칙을 적용하지 않고,

저장된 비밀번호와 다른 값이면 validation 규칙을 적용하는 것이다.

 

$("userPw").bind("change", function(){
  //비밀번호 변경되지 않음
  if($("#userPw").val() == $("#userDbPw").val()) {
    $("#userPw").rules('remove', {
                        ragelength:[9, 20]
                        ,checkUserPwNum:true
     });
  } else {
      //변경된 경우
      $("#userPw").rules('add', {
                      ragelength:[9, 20]
                      ,checkUserPwNum:true
      });
  }
});
반응형

+ Recent posts