PageRenderTime 213ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/backend/Atlant/js/plugins/validationengine/languages/jquery.validationEngine-en.js

https://gitlab.com/kaouech/theme
JavaScript | 206 lines | 184 code | 5 blank | 17 comment | 8 complexity | a042f21c86b706e347f349ad1d919dbc MD5 | raw file
  1. (function($){
  2. $.fn.validationEngineLanguage = function(){
  3. };
  4. $.validationEngineLanguage = {
  5. newLang: function(){
  6. $.validationEngineLanguage.allRules = {
  7. "required": { // Add your regex rules here, you can take telephone as an example
  8. "regex": "none",
  9. "alertText": "* This field is required",
  10. "alertTextCheckboxMultiple": "* Please select an option",
  11. "alertTextCheckboxe": "* This checkbox is required",
  12. "alertTextDateRange": "* Both date range fields are required"
  13. },
  14. "requiredInFunction": {
  15. "func": function(field, rules, i, options){
  16. return (field.val() == "test") ? true : false;
  17. },
  18. "alertText": "* Field must equal test"
  19. },
  20. "dateRange": {
  21. "regex": "none",
  22. "alertText": "* Invalid ",
  23. "alertText2": "Date Range"
  24. },
  25. "dateTimeRange": {
  26. "regex": "none",
  27. "alertText": "* Invalid ",
  28. "alertText2": "Date Time Range"
  29. },
  30. "minSize": {
  31. "regex": "none",
  32. "alertText": "* Minimum ",
  33. "alertText2": " characters required"
  34. },
  35. "maxSize": {
  36. "regex": "none",
  37. "alertText": "* Maximum ",
  38. "alertText2": " characters allowed"
  39. },
  40. "groupRequired": {
  41. "regex": "none",
  42. "alertText": "* You must fill one of the following fields",
  43. "alertTextCheckboxMultiple": "* Please select an option",
  44. "alertTextCheckboxe": "* This checkbox is required"
  45. },
  46. "min": {
  47. "regex": "none",
  48. "alertText": "* Minimum value is "
  49. },
  50. "max": {
  51. "regex": "none",
  52. "alertText": "* Maximum value is "
  53. },
  54. "past": {
  55. "regex": "none",
  56. "alertText": "* Date prior to "
  57. },
  58. "future": {
  59. "regex": "none",
  60. "alertText": "* Date past "
  61. },
  62. "maxCheckbox": {
  63. "regex": "none",
  64. "alertText": "* Maximum ",
  65. "alertText2": " options allowed"
  66. },
  67. "minCheckbox": {
  68. "regex": "none",
  69. "alertText": "* Please select ",
  70. "alertText2": " options"
  71. },
  72. "equals": {
  73. "regex": "none",
  74. "alertText": "* Fields do not match"
  75. },
  76. "creditCard": {
  77. "regex": "none",
  78. "alertText": "* Invalid credit card number"
  79. },
  80. "phone": {
  81. // credit: jquery.h5validate.js / orefalo
  82. "regex": /^([\+][0-9]{1,3}([ \.\-])?)?([\(][0-9]{1,6}[\)])?([0-9 \.\-]{1,32})(([A-Za-z \:]{1,11})?[0-9]{1,4}?)$/,
  83. "alertText": "* Invalid phone number"
  84. },
  85. "email": {
  86. // HTML5 compatible email regex ( http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html# e-mail-state-%28type=email%29 )
  87. "regex": /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
  88. "alertText": "* Invalid email address"
  89. },
  90. "fullname": {
  91. "regex":/^([a-zA-Z]+[\'\,\.\-]?[a-zA-Z ]*)+[ ]([a-zA-Z]+[\'\,\.\-]?[a-zA-Z ]+)+$/,
  92. "alertText":"* Must be first and last name"
  93. },
  94. "zip": {
  95. "regex":/^\d{5}$|^\d{5}-\d{4}$/,
  96. "alertText":"* Invalid zip format"
  97. },
  98. "integer": {
  99. "regex": /^[\-\+]?\d+$/,
  100. "alertText": "* Not a valid integer"
  101. },
  102. "number": {
  103. // Number, including positive, negative, and floating decimal. credit: orefalo
  104. "regex": /^[\-\+]?((([0-9]{1,3})([,][0-9]{3})*)|([0-9]+))?([\.]([0-9]+))?$/,
  105. "alertText": "* Invalid floating decimal number"
  106. },
  107. "date": {
  108. // Check if date is valid by leap year
  109. "func": function (field) {
  110. var pattern = new RegExp(/^(\d{4})[\/\-\.](0?[1-9]|1[012])[\/\-\.](0?[1-9]|[12][0-9]|3[01])$/);
  111. var match = pattern.exec(field.val());
  112. if (match == null)
  113. return false;
  114. var year = match[1];
  115. var month = match[2]*1;
  116. var day = match[3]*1;
  117. var date = new Date(year, month - 1, day); // because months starts from 0.
  118. return (date.getFullYear() == year && date.getMonth() == (month - 1) && date.getDate() == day);
  119. },
  120. "alertText": "* Invalid date, must be in YYYY-MM-DD format"
  121. },
  122. "ipv4": {
  123. "regex": /^((([01]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))[.]){3}(([0-1]?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))$/,
  124. "alertText": "* Invalid IP address"
  125. },
  126. "url": {
  127. "regex": /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,
  128. "alertText": "* Invalid URL"
  129. },
  130. "onlyNumberSp": {
  131. "regex": /^[0-9\ ]+$/,
  132. "alertText": "* Numbers only"
  133. },
  134. "onlyLetterSp": {
  135. "regex": /^[a-zA-Z\ \']+$/,
  136. "alertText": "* Letters only"
  137. },
  138. "onlyLetterAccentSp":{
  139. "regex": /^[a-z\u00C0-\u017F\ ]+$/i,
  140. "alertText": "* Letters only (accents allowed)"
  141. },
  142. "onlyLetterNumber": {
  143. "regex": /^[0-9a-zA-Z]+$/,
  144. "alertText": "* No special characters allowed"
  145. },
  146. // --- CUSTOM RULES -- Those are specific to the demos, they can be removed or changed to your likings
  147. "ajaxUserCall": {
  148. "url": "ajaxValidateFieldUser",
  149. // you may want to pass extra data on the ajax call
  150. "extraData": "name=eric",
  151. "alertText": "* This user is already taken",
  152. "alertTextLoad": "* Validating, please wait"
  153. },
  154. "ajaxUserCallPhp": {
  155. "url": "phpajax/ajaxValidateFieldUser.php",
  156. // you may want to pass extra data on the ajax call
  157. "extraData": "name=eric",
  158. // if you provide an "alertTextOk", it will show as a green prompt when the field validates
  159. "alertTextOk": "* This username is available",
  160. "alertText": "* This user is already taken",
  161. "alertTextLoad": "* Validating, please wait"
  162. },
  163. "ajaxNameCall": {
  164. // remote json service location
  165. "url": "ajaxValidateFieldName",
  166. // error
  167. "alertText": "* This name is already taken",
  168. // if you provide an "alertTextOk", it will show as a green prompt when the field validates
  169. "alertTextOk": "* This name is available",
  170. // speaks by itself
  171. "alertTextLoad": "* Validating, please wait"
  172. },
  173. "ajaxNameCallPhp": {
  174. // remote json service location
  175. "url": "phpajax/ajaxValidateFieldName.php",
  176. // error
  177. "alertText": "* This name is already taken",
  178. // speaks by itself
  179. "alertTextLoad": "* Validating, please wait"
  180. },
  181. "validate2fields": {
  182. "alertText": "* Please input HELLO"
  183. },
  184. //tls warning:homegrown not fielded
  185. "dateFormat":{
  186. "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(?:(?:0?[1-9]|1[0-2])(\/|-)(?:0?[1-9]|1\d|2[0-8]))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^(0?2(\/|-)29)(\/|-)(?:(?:0[48]00|[13579][26]00|[2468][048]00)|(?:\d\d)?(?:0[48]|[2468][048]|[13579][26]))$/,
  187. "alertText": "* Invalid Date"
  188. },
  189. //tls warning:homegrown not fielded
  190. "dateTimeFormat": {
  191. "regex": /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1}$|^(?:(?:(?:0?[13578]|1[02])(\/|-)31)|(?:(?:0?[1,3-9]|1[0-2])(\/|-)(?:29|30)))(\/|-)(?:[1-9]\d\d\d|\d[1-9]\d\d|\d\d[1-9]\d|\d\d\d[1-9])$|^((1[012]|0?[1-9]){1}\/(0?[1-9]|[12][0-9]|3[01]){1}\/\d{2,4}\s+(1[012]|0?[1-9]){1}:(0?[1-5]|[0-6][0-9]){1}:(0?[0-6]|[0-6][0-9]){1}\s+(am|pm|AM|PM){1})$/,
  192. "alertText": "* Invalid Date or Date Format",
  193. "alertText2": "Expected Format: ",
  194. "alertText3": "mm/dd/yyyy hh:mm:ss AM|PM or ",
  195. "alertText4": "yyyy-mm-dd hh:mm:ss AM|PM"
  196. }
  197. };
  198. }
  199. };
  200. $.validationEngineLanguage.newLang();
  201. })(jQuery);