Commit ff44521b authored by mattwire's avatar mattwire

Fix issues with form validation when you have 'On behalf of organisation'...

Fix issues with form validation when you have 'On behalf of organisation' block on the contribution page
parent 63e8242f
......@@ -28,6 +28,7 @@ Where:
* Add check for recommended SweetAlert extension.
* Fix [#208](https://lab.civicrm.org/extensions/stripe/issues/182) use window.alert if SweetAlert is not installed.
* Make sure we reset submitted flag if we are not able to submit the form.
* Fix issues with form validation when you enable the "On behalf of Organisation" block on contribution pages - see https://lab.civicrm.org/extensions/stripe/-/issues/147#note_38994 and https://github.com/civicrm/civicrm-core/pull/17672.
## Release 6.4
**This release REQUIRES that you upgrade mjwshared to 0.7 and your Stripe API version must be 2019-12-03 or newer.**
......
......@@ -14,8 +14,8 @@
<author>Matthew Wire (MJW Consulting)</author>
<email>mjw@mjwconsult.co.uk</email>
</maintainer>
<releaseDate>2020-06-16</releaseDate>
<version>6.4.1-beta4</version>
<releaseDate>2020-06-20</releaseDate>
<version>6.4.1-beta5</version>
<develStage>beta</develStage>
<compatibility>
<ver>5.24</ver>
......
......@@ -768,9 +768,29 @@ CRM.$(function($) {
$('div#priceset input[type="checkbox"]').each(function() {
$(this).attr('name', $(this).attr('name').split('[').shift());
});
// @todo remove once min version is 5.28 (https://github.com/civicrm/civicrm-core/pull/17672)
var is_for_organization = $('#is_for_organization');
if (is_for_organization.length) {
setValidateOnBehalfOfBlock();
is_for_organization.on('change', function() {
setValidateOnBehalfOfBlock();
});
}
function setValidateOnBehalfOfBlock() {
if (is_for_organization.is(':checked')) {
$('#onBehalfOfOrg select.crm-select2').removeClass('crm-no-validate');
}
else {
$('#onBehalfOfOrg select.crm-select2').addClass('crm-no-validate');
}
}
var validator = $(form).validate();
validator.settings.errorClass = 'crm-inline-error alert-danger';
validator.settings.ignore = '.select2-offscreen, [readonly], :hidden:not(.crm-select2)';
validator.settings.ignore = '.select2-offscreen, [readonly], :hidden:not(.crm-select2), .crm-no-validate';
validator.settings.ignoreTitle = true;
// Default email validator accepts test@example but on test@example.org is valid (https://jqueryvalidation.org/jQuery.validator.methods/)
$.validator.methods.email = function( value, element ) {
// Regex from https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment