Skip to content

Instantly share code, notes, and snippets.

@andromedarabbit
Created December 28, 2012 10:15
Show Gist options
  • Save andromedarabbit/4396632 to your computer and use it in GitHub Desktop.
Save andromedarabbit/4396632 to your computer and use it in GitHub Desktop.
JQuery Validator 의 커스터마이징
<script type="text/javascript">
<!--
JQuery Validator의 경고 메시지를 alert 창에 표시한다.
-->
$(document).ready(function(){
$.validator.setDefaults({
onkeyup: false
, onclick: false
, onfocusout: false
, showErrors: function(errorMap, errorList) {
if(errorList.length < 1)
return;
alert(errorList[0].message);
}
});
});
$(document).ready(function(){
$("#update_form").validate({
rules: {
title: {
required: true,
minlength: 2,
maxlength: 30
},
description: {
required: true,
minlength: 10,
maxlength: 500
}
},
messages : {
title : {
required : '시리즈 제목을 써주세요.'
, minlength : $.validator.format('시리즈 제목은 {0}자 이상이어야 합니다.')
, maxlength : $.validator.format('시리즈 제목은 {0}자 이이어야 합니다.')
},
description : {
required : '상품소개를 써주세요.'
, minlength : $.validator.format('상품 소개글은 {0}자 이상여야 합니다.')
, maxlength : $.validator.format('상품 소개글은 {0}자 이하여야 합니다.')
}
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment