Created
February 10, 2014 17:12
-
-
Save mlutfy/8920137 to your computer and use it in GitHub Desktop.
templates/CRM/Contribute/Form/Contribution/Main.extra.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{* [ML] fork of templates/CRM/Form/validate.tpl specific for public contribute pages *} | |
{* 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: {} | |
}; | |
// use civicrm notifications when there are errors | |
params.invalidHandler = function(form, validator) { | |
var errors = validator.errorList; | |
{/literal}{if !$urlIsPublic}{literal} | |
for (var i in errors) { | |
$(errors[i].element).crmError(errors[i].message); | |
} | |
{/literal}{else} | |
// [ML] No need to alert, obvious enough... | |
// [ML] alert("{ts escape='js'}Please review and correct the highlighted fields before continuing.{/ts}"); | |
{/if}{literal} | |
}; | |
params.submitHandler = paymentconfirmpopup_show_popup; | |
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.length) { | |
$.each(CRM.validate.functions, function(i, func) { | |
func(); | |
}); | |
} | |
{/literal} | |
{/if} | |
}); | |
</script> | |
{/if} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment