Closed remcotolsma closed 1 year ago
But is there a specific reason why the autocomplete request isn't firing if a mask is active? See video.
https://user-images.githubusercontent.com/1701552/152130764-7f5c744e-e047-4a8b-866d-0b954ddace9f.mov
.
I see that Gravity Forms uses the following library: https://github.com/RubtsovAV/jquery.maskedinput/blob/1.4.1/src/jquery.maskedinput.js#L254. We hook into the change
event within Pronamic Maps, but apparently jquery.maskedinput
does something that prevents that event from being executed (preventDefault()
?)
The jquery.maskedinput
library is also a bit outdated:
https://github.com/digitalBush/jquery.maskedinput
Notice: This project is no longer being maintained.
I started this project over 10 years ago to fill a need for a side project I was working on at the time. Nothing ever became of that side project, but this little plugin lived on. Over the years it brought me joy to stumble on sites using this thing. It was super encouraging to hear from people using it in their own products. I tried for a while to maintain it, even after I had moved away from front end web development.
The time has come to officially call it quits. The web has changed(A LOT) and there are better things out there like Cleave.js. I'll leave this repo up for posterity in an archived state. Thank you to everyone who contributed to or used this plugin over the years.
As far as i can see, there is no easy way to add support for the outdated jquery.maskedinput
library.
The jquery.maskedinput
library executes the deprecated jQuery.fn.change()
function:
This seems to be a jQuery event which can't be handled through a addEventListener
function.
Therefor did the following change:
var gravityforms = document.querySelectorAll( '.gform_wrapper' );
gravityforms.forEach( ( gravityform ) => {
gravityform.addEventListener( 'change', function( event ) {
pronamicMapsAutocomplete( gravityform, event.target );
} );
pronamicMapsAutocomplete( gravityform );
} );
to:
jQuery( '.gform_wrapper' ).on( 'change', function( event ) {
pronamicMapsAutocomplete( this, event.target );
} );
https://github.com/pronamic/wp-pronamic-maps/commit/457a4f768d4b14017cea7e86c2e366d7520d394d
I think that no further action is needed within this issue for now.
Gravity Forms does have support for masks:
Admin
Preview
I think Gravity Forms uses the following library: https://github.com/igorescobar/jQuery-Mask-Plugin
I don't think it is very easy for a third party to check whether a Gravity Forms field has been filled in correctly / completely.
There is also the HTML input
pattern
attribute. https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/patternWe could use this in combination with the
checkValidity
method:In https://gitlab.com/pronamic-themes/dmb/-/blob/develop/js/script.js#L210-251 is also some custom code in place for validation.
We could also use
minlength
andmaxlength
attributes: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text