en.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*********************************
  2. * Themes, rules, and i18n support
  3. * Locale: English
  4. *********************************/
  5. (function ($) {
  6. /* Global configuration
  7. */
  8. $.validator.config({
  9. //stopOnError: false,
  10. //theme: 'yellow_right',
  11. defaultMsg: "This field is not valid.",
  12. loadingMsg: "Validating...",
  13. // Custom rules
  14. rules: {
  15. digits: [/^\d+$/, "Please enter only digits."]
  16. }
  17. });
  18. /* Default error messages
  19. */
  20. $.validator.config({
  21. messages: {
  22. required: "This field is required.",
  23. remote: "Please try another name.",
  24. integer: {
  25. '*': "Please enter an integer.",
  26. '+': "Please enter a positive integer.",
  27. '+0': "Please enter a positive integer or 0.",
  28. '-': "Please enter a negative integer.",
  29. '-0': "Please enter a negative integer or 0."
  30. },
  31. match: {
  32. eq: "{0} must be equal to {1}.",
  33. neq: "{0} must be not equal to {1}.",
  34. lt: "{0} must be less than {1}.",
  35. gt: "{0} must be greater than {1}.",
  36. lte: "{0} must be less than or equal to {1}.",
  37. gte: "{0} must be greater than or equal to {1}."
  38. },
  39. range: {
  40. rg: "Please enter a number between {1} and {2}.",
  41. gt: "Please enter a number greater than or equal to {1}.",
  42. lt: "Please enter a number less than or equal to {1}."
  43. },
  44. checked: {
  45. eq: "Please check {1} items.",
  46. rg: "Please check between {1} and {2} items.",
  47. gt: "Please check at least {1} items.",
  48. lt: "Please check no more than {1} items."
  49. },
  50. length: {
  51. eq: "Please enter {1} characters.",
  52. rg: "Please enter a value between {1} and {2} characters long.",
  53. gt: "Please enter at least {1} characters.",
  54. lt: "Please enter no more than {1} characters.",
  55. eq_2: "",
  56. rg_2: "",
  57. gt_2: "",
  58. lt_2: ""
  59. }
  60. }
  61. });
  62. /* Themes
  63. */
  64. var TPL_ARROW = '<span class="n-arrow"><b>◆</b><i>◆</i></span>';
  65. $.validator.setTheme({
  66. 'simple_right': {
  67. formClass: 'n-simple',
  68. msgClass: 'n-right'
  69. },
  70. 'simple_bottom': {
  71. formClass: 'n-simple',
  72. msgClass: 'n-bottom'
  73. },
  74. 'yellow_top': {
  75. formClass: 'n-yellow',
  76. msgClass: 'n-top',
  77. msgArrow: TPL_ARROW
  78. },
  79. 'yellow_right': {
  80. formClass: 'n-yellow',
  81. msgClass: 'n-right',
  82. msgArrow: TPL_ARROW
  83. },
  84. 'yellow_right_effect': {
  85. formClass: 'n-yellow',
  86. msgClass: 'n-right',
  87. msgArrow: TPL_ARROW,
  88. msgShow: function($msgbox, type){
  89. var $el = $msgbox.children();
  90. if ($el.is(':animated')) return;
  91. if (type === 'error') {
  92. $el.css({
  93. left: '20px',
  94. opacity: 0
  95. }).delay(100).show().stop().animate({
  96. left: '-4px',
  97. opacity: 1
  98. }, 150).animate({
  99. left: '3px'
  100. }, 80).animate({
  101. left: 0
  102. }, 80);
  103. } else {
  104. $el.css({
  105. left: 0,
  106. opacity: 1
  107. }).fadeIn(200);
  108. }
  109. },
  110. msgHide: function($msgbox, type){
  111. var $el = $msgbox.children();
  112. $el.stop().delay(100).show().animate({
  113. left: '20px',
  114. opacity: 0
  115. }, 300, function(){
  116. $msgbox.hide();
  117. });
  118. }
  119. }
  120. });
  121. })(jQuery);