• Resolved hhgk

    (@hhgk)


    Since some time we are experiencing problems with the validation function in our forms. For instance when you click on a checkbox the following error occurs:

    validateRequired.js:79 Uncaught TypeError: currentValue.trim is not a function at n.validateModelData (validateRequired.js:79:1) at p (backbone.min.js?ver=1.4.1:2:3700) at f (backbone.min.js?ver=1.4.1:2:3497) at a (backbone.min.js?ver=1.4.1:2:692) at e.trigger (backbone.min.js?ver=1.4.1:2:3380) at n.changeValue (fieldModel.js:83:1) at p (backbone.min.js?ver=1.4.1:2:3818) at f (backbone.min.js?ver=1.4.1:2:3497) at a (backbone.min.js?ver=1.4.1:2:692) at e.trigger (backbone.min.js?ver=1.4.1:2:3380)


    I could find the problem in the front-end.js:

    validateModelData: function(e) {
    if (1 != e.get("required") || !e.get("visible") || e.get("clean")) return !1;
    if (e.get("errors").get("required-error")) return !1;
    currentValue = e.get("value");
    var t = !0;
    <span style="text-decoration: underline;">currentValue.trim()</span> || (t = !1);
    var i = nfRadio.channel(e.get("type")).request("validate:modelData", e);
    if (void 0 !== i) var n = i;
    else n = t;
    this.maybeError(n, e)
    },

    To get around this error I corrected the code this way:

    validateModelData: function(e) {
        if (1 != e.get("required") || !e.get("visible") || e.get("clean")) return !1;
        if (e.get("errors").get("required-error")) return !1;
        var currentValue = e.get("value");
        var t = !0;
        
        <span style="text-decoration: underline;">if (typeof currentValue === "string" && !currentValue.trim()) {
            t = !1;
        }</span>
        
        var i = nfRadio.channel(e.get("type")).request("validate:modelData", e);
        var n = (void 0 !== i) ? i : t;
        this.maybeError(n, e);
    }

    Is it possible to get an update for this?

    Regards,

    Holger

    • This topic was modified 1 year, 6 months ago by hhgk.

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • thanks, this solution helped!

    all my websites using the latest ninja forms 3.6.30 are affected by this issue. rolling out your temp fix as i type this…

    i also contacted the NF support and linked them to your post – thanks again for sharing your solution.

    where is that js file located ? I am having same issue and unable to find the file your referencing. Thanks

    if i remember it correctly it’s right there: /ninja-forms/assets/js/min/front-end.js

    but it is a minified file, so not too easy to edit.

    Shaylee

    (@shayleehansen30)

    I’m sorry to hear that you’re experiencing this.

    Please contact our Customer Support team, describe the issue, and provide them with the error message and details you’ve shared here. They will be best equipped to assist you further.

    Thank you for bringing this to our attention, and we appreciate your understanding as we work to resolve this matter.

    Hi Shaylee,

    Is there a fix on the way for this? It’s causing us a lot of grief across nearly 100 sites that we manage!

    Regards, Akiko Design.

    same here

    The front-end.js file is located in

    public_html/wp-content/plugins/ninja-forms/assets/js/min

    an easier fix is that just do a search for currentValue.trim() and change it to currentValue.

    It works for me

    Proposed solution didn’t seem to work for me. It seems as through currentValue exist, but it does not have a trim method.

    I did the hotfix by only replacing the small part in wp-content/plugins/ninja-forms/assets/js/min/front-end.js:

    Before: currentValue.trim()||(t=!1);
    After: currentValue&&currentValue.trim?currentValue.trim():(t=!1);

    This solved it for me, for now.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘validateRequired.js:79 Uncaught TypeError: currentValue.trim is not a function’ is closed to new replies.