JavaScript error after selecting a file from a required file field
-
Hi, I have an issue on a form which I have basically narrowed down to happening when a [file] field is set to “required”, e.g.
[file* documents id:documents class:required-field limit:4mb filetypes:jpg|jpeg|pdf]When I select a file I get this JavaScript error in the browser console after selecting the file:
Unhandled Promise Rejection: TypeError: t.trim is not a function. (In 't.trim()', 't.trim' is undefined)I am then unable to submit the form as the validation still thinks that there is an invalid field.
After a fair bit of googling etc trying to troubleshoot it seems like this relates to the underlying SWV validation in CF7. So for some reason when a file field is set to “required” it triggers this error, without “required” it works just fine.
Unfortunately troubleshooting this issue has been a little more complicated in that I actually have a Staging and a Live version of the site, but the issue is only occurring on the Staging version. I have exactly the same theme, form template HTML, JavaScript on both sites (running on the same server, PHP version etc), but it only occurs on the Staging site.
I’m not sure if it’s helpful / relevant or not but if I compare the SWV schemas for the form on both Staging and Live and they don’t seem to match, specifically on Staging it has this 4th ruleset related to the “documents” field:
{
"rule": "required",
"field": "documents",
"error": "The field is required."
}The other rulesets for “documents” that are in the schema on both Staging and Live are these:
{
"rule": "requiredfile",
"field": "documents",
"error": "The field is required."
},
{
"rule": "file",
"field": "documents",
"accept": [
".jpg",
".jpeg",
".pdf"
],
"error": "You are not allowed to upload files of this type."
},
{
"rule": "maxfilesize",
"field": "documents",
"threshold": 4194304,
"error": "The file is too big."
},Thanks for any help!
The topic ‘JavaScript error after selecting a file from a required file field’ is closed to new replies.