Skip to content
Snippets Groups Projects
Commit ff44521b authored by mattwire's avatar mattwire
Browse files

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
No related branches found
No related tags found
1 merge request!1146.4.1
...@@ -28,6 +28,7 @@ Where: ...@@ -28,6 +28,7 @@ Where:
* Add check for recommended SweetAlert extension. * Add check for recommended SweetAlert extension.
* Fix [#208](https://lab.civicrm.org/extensions/stripe/issues/182) use window.alert if SweetAlert is not installed. * 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. * 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 ## 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.** **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 @@ ...@@ -14,8 +14,8 @@
<author>Matthew Wire (MJW Consulting)</author> <author>Matthew Wire (MJW Consulting)</author>
<email>mjw@mjwconsult.co.uk</email> <email>mjw@mjwconsult.co.uk</email>
</maintainer> </maintainer>
<releaseDate>2020-06-16</releaseDate> <releaseDate>2020-06-20</releaseDate>
<version>6.4.1-beta4</version> <version>6.4.1-beta5</version>
<develStage>beta</develStage> <develStage>beta</develStage>
<compatibility> <compatibility>
<ver>5.24</ver> <ver>5.24</ver>
......
...@@ -768,9 +768,29 @@ CRM.$(function($) { ...@@ -768,9 +768,29 @@ CRM.$(function($) {
$('div#priceset input[type="checkbox"]').each(function() { $('div#priceset input[type="checkbox"]').each(function() {
$(this).attr('name', $(this).attr('name').split('[').shift()); $(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(); var validator = $(form).validate();
validator.settings.errorClass = 'crm-inline-error alert-danger'; 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/) // 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 ) { $.validator.methods.email = function( value, element ) {
// Regex from https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address // Regex from https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment