{*
+--------------------------------------------------------------------+
- | CiviCRM version 4.3 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
{* Initialize jQuery validate *}
{* Extra params and functions may be added to the CRM.validate object before this template is loaded *}
+{if !$crm_form_validate_included}
+{assign var=crm_form_validate_included value=1}
+
{literal}
<script type="text/javascript" >
cj(function($) {
+ var messages = {{/literal}
+ required: "{ts escape='js'}This field is required.{/ts}",
+ remote: "{ts escape='js'}Please fix this field.{/ts}",
+ email: "{ts escape='js'}Please enter a valid email address.{/ts}",
+ url: "{ts escape='js'}Please enter a valid URL.{/ts}",
+ date: "{ts escape='js'}Please enter a valid date.{/ts}",
+ dateISO: "{ts escape='js'}Please enter a valid date (YYYY-MM-DD).{/ts}",
+ number: "{ts escape='js'}Please enter a valid number.{/ts}",
+ digits: "{ts escape='js'}Please enter only digits.{/ts}",
+ creditcard: "{ts escape='js'}Please enter a valid credit card number.{/ts}",
+ equalTo: "{ts escape='js'}Please enter the same value again.{/ts}",
+ accept: "{ts escape='js'}Please enter a value with a valid extension.{/ts}",
+ maxlength: $.validator.format("{ts escape='js'}Please enter no more than {ldelim}0{rdelim} characters.{/ts}"),
+ minlength: $.validator.format("{ts escape='js'}Please enter at least {ldelim}0{rdelim} characters.{/ts}"),
+ rangelength: $.validator.format("{ts escape='js'}Please enter a value between {ldelim}0{rdelim} and {ldelim}1{rdelim} characters long.{/ts}"),
+ range: $.validator.format("{ts escape='js'}Please enter a value between {ldelim}0{rdelim} and {ldelim}1{rdelim}.{/ts}"),
+ max: $.validator.format("{ts escape='js'}Please enter a value less than or equal to {ldelim}0{rdelim}.{/ts}"),
+ min: $.validator.format("{ts escape='js'}Please enter a value greater than or equal to {ldelim}0{rdelim}.{/ts}")
+ {literal}};
+
var params = {
'errorClass': 'crm-inline-error',
- messages: {{/literal}
- required: "{ts escape='js'}This field is required.{/ts}",
- remote: "{ts escape='js'}Please fix this field.{/ts}",
- email: "{ts escape='js'}Please enter a valid email address.{/ts}",
- url: "{ts escape='js'}Please enter a valid URL.{/ts}",
- date: "{ts escape='js'}Please enter a valid date.{/ts}",
- dateISO: "{ts escape='js'}Please enter a valid date (ISO).{/ts}",
- number: "{ts escape='js'}Please enter a valid number.{/ts}",
- digits: "{ts escape='js'}Please enter only digits.{/ts}",
- creditcard: "{ts escape='js'}Please enter a valid credit card number.{/ts}",
- equalTo: "{ts escape='js'}Please enter the same value again.{/ts}",
- accept: "{ts escape='js'}Please enter a value with a valid extension.{/ts}",
- maxlength: $.validator.format("{ts escape='js'}Please enter no more than {ldelim}0{rdelim} characters.{/ts}"),
- minlength: $.validator.format("{ts escape='js'}Please enter at least {ldelim}0{rdelim} characters.{/ts}"),
- rangelength: $.validator.format("{ts escape='js'}Please enter a value between {ldelim}0{rdelim} and {ldelim}1{rdelim} characters long.{/ts}"),
- range: $.validator.format("{ts escape='js'}Please enter a value between {ldelim}0{rdelim} and {ldelim}1{rdelim}.{/ts}"),
- max: $.validator.format("{ts escape='js'}Please enter a value less than or equal to {ldelim}0{rdelim}.{/ts}"),
- min: $.validator.format("{ts escape='js'}Please enter a value greater than or equal to {ldelim}0{rdelim}.{/ts}")
- {literal}}
+ messages: {}
};
// use civicrm notifications when there are errors
CRM.validate.params = CRM.validate.params || {};
$.extend(CRM.validate.params, params);
+ $.extend($.validator.messages, messages);
{/literal}
{if $form && $form.formName}
$("#{$form.formName}").validate(params);
{literal}
// Call any post-initialization callbacks
- if (CRM.validate && CRM.validate.functions) {
- for (var i in CRM.validate.functions) {
- CRM.validate.functions[i]();
- }
+ if (CRM.validate && CRM.validate.functions.length) {
+ $.each(CRM.validate.functions, function(i, func) {
+ func();
+ });
}
{/literal}
{/if}
});
</script>
+{/if}