未捕获的TypeError:对象#< Object>没有方法“验证" [英] Uncaught TypeError: Object #<Object> has no method 'validate'

查看:68
本文介绍了未捕获的TypeError:对象#< Object>没有方法“验证"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在表单上调用validate()函数时,出现标题错误.我所做的所有研究都说确保您正在打电话",但是我有95%的把握是因为这是我的电话:

I am getting the titular error when I try to call the validate() function on my form. All the research I have done says "make sure you're calling it" however I am 95% sure I am as this is my call:

<script type="text/javascript" src="http://test.elitetradersgroup.com.au/wp-content/plugins/a-test/jquery.validate.min.js?ver=3.3.2"></script>
<script type="text/javascript" src="http://test.elitetradersgroup.com.au/wp-content/plugins/a-test/additional-methods.min.js?ver=3.3.2"></script>

当我在Chrome开发工具中单击它们时,它们会附带插件文件,使我相信它们已包含在内.他们是在jQuery之后被调用的,因此我对此表示高度怀疑.

When I click on them in Chromes dev tools they come up with the plugin files, leading me to believe they are included. They are being called after jQuery so I highly doubt it's that.

表单如下:

<form action="http://test.elitetradersgroup.com.au/broker-tools/amazon-upload/" method="post" class="upload" enctype="multipart/form-data">
    <label class="title hide" for="theTitle">Email Title</label>
    <input id="theTitle" class="hide" type="text" name="theTitle"><div id="amazon_title_char_count" class="hide"></div><div id="excess_warning" style="display:none; font-weight: bold;color: red;"></div>

    <label class="title hide" for="theSite">Select Email From</label>

        <div class="option hide"><span class="sec_name">Elite Traders Group</span><div class="opt-cont"><input class="radio broadcast" type="radio" id="sec_2" name="theSite" value="s_2"><label class="radio" for="sec_2">Broadcast</label></div></div><div class="option hide"><span class="sec_name">Elite Futures Mastery</span><div class="opt-cont"><input class="radio broadcast" type="radio" id="sec_6" name="theSite" value="s_6"><label class="radio" for="sec_6">Broadcast</label></div><div class="opt-cont"><input class="radio daily-forex-room" type="radio" id="sec_10" name="theSite" value="s_10"><label class="radio" for="sec_10">Daily Forex Room</label></div><div class="opt-cont"><input class="radio day-ahead" type="radio" id="sec_3" name="theSite" value="s_3"><label class="radio" for="sec_3">Day Ahead</label></div><div class="opt-cont"><input class="radio the-daily-beef" type="radio" id="sec_9" name="theSite" value="s_9"><label class="radio" for="sec_9">The Daily Beef</label></div><div class="opt-cont"><input class="radio trade-progress" type="radio" id="sec_5" name="theSite" value="s_5"><label class="radio" for="sec_5">Trade Progress</label></div><div class="opt-cont"><input class="radio trade-recommendation" type="radio" id="sec_11" name="theSite" value="s_11"><label class="radio" for="sec_11">Trade Recommendation</label></div><div class="opt-cont"><input class="radio week-ahead" type="radio" id="sec_4" name="theSite" value="s_4"><label class="radio" for="sec_4">Week Ahead</label></div></div><div class="option hide"><span class="sec_name">Daily Wealth Report</span><div class="opt-cont"><input class="radio technical-toolbox" type="radio" id="sec_1" name="theSite" value="s_1"><label class="radio" for="sec_1">Technical Toolbox</label></div></div><div class="option hide"><span class="sec_name">Elite Options Mastery</span><div class="opt-cont"><input class="radio broadcast" type="radio" id="sec_7" name="theSite" value="s_7"><label class="radio" for="sec_7">Broadcast</label></div></div><div class="option hide"><span class="sec_name">Options Made Easy</span><div class="opt-cont"><input class="radio broadcast" type="radio" id="sec_8" name="theSite" value="s_8"><label class="radio" for="sec_8">Broadcast</label></div></div>    

<label class="title hide">Files to include</label>
<div id="container">
    <div id="filelist"></div>
    <div id="queue-time"></div>
    <br>
    <a id="pickfiles" class="hide" href="#">[Select files]</a>

</div>

    <label class="title hide">Extras</label>

    <input type="checkbox" class="hide" id="positons" name="positions" value="positions-box"><label class="hide" for="positons">Include Positions</label>
    <input type="checkbox" class="hide" id="message" name="message" value="message-box"><label class="hide" for="message">Include message</label>
    <input type="checkbox" class="hide" id="additional-webinar" name="additional-webinar" value="additional-webinar-box"><label class="hide" for="additional-webinar">Include Additional Webinar</label>

    <div class="hide" id="positions-box" style="display:none;">
        <label class="title">Positions Info</label>
        <label>New/Potential Trades</label>
        <input type="text" name="np-trades">
        <label>Current Trades</label>
        <input type="text" name="cur-trades">
        <label>Updates</label>
        <input type="text" name="update-trades">
    </div>
    <div class="hide" id="message-box" style="display:none;">
        <label class="title">Email Message</label>
        <textarea id="message-ta" name="message" cols="50" rows="10"></textarea>
        <div id="message_char_count"></div>
        <div id="message_excess_warning" style="display:none; font-weight: bold;color: red;"></div>
    </div>
    <div class="hide" id="additional-webinar-box" style="display:none;">
        <label class="title">Select Additional Webinar</label>
        <select name="additional-webinar-selection">
            <option value="0" selected="">Please Select</option>
            <option value="173">Del All test(Elite Options Mastery)</option><option value="171">Glob Test(Elite Futures Mastery)</option><option value="169">Test 2(Elite Futures Mastery)</option><option value="167">Test(Elite Futures Mastery)</option><option value="164">Test(Elite Futures Mastery)</option><option value="162">New Min TEst(Elite Futures Mastery)</option><option value="160">Min Height Test(Elite Options Mastery)</option><option value="158">Title Yo(Elite Options Mastery)</option><option value="156">Title(Options Made Easy)</option><option value="96">TT Test(Daily Wealth Report)</option>        </select>
    </div>

    <input type="hidden" value="elitetradersgroup" name="amazon_bucket">
    <button class="hide" id="validate" type="button" onclick="broker_validate()">Validate</button>
    <button class="hide" id="juploader" type="button" style="display:none">Upload</button>
<input type="hidden" name="uid" value="p16ubcu16t1gus18ls12g79ls1"></form>

像这样的通话

<script type="text/javascript">
    function broker_validate() {
        jQuery("form").validate({ //line where the error pops up in console
            rules: {
                theTitle: {
                    required: true
                },
            messages: {
                theTitle: {
                    required: "The email needs a title"
                }
            }
            }
        })

        if (jQuery("form").valid()) {
            jQuery("#validate").hide();
            jQuery("#juploader").show();
        }

    };

</script>

这件事让我感到难过,我确定这是一个愚蠢的小语法或优先级错误.眼睛新鲜的人可以发现它吗?

This thing has me stumped, I am sure it's a stupid little syntax or priority error. Can anybody with fresh eyes spot it?

仅供参考,该网站正在运行wordpress,您可能可以通过从插件文件中提取jQuery来判断.

FYI the site is running wordpress, as you may be able to tell by the jQuery being pulled from a plugins file.

为回应评论,这里是console.log(jQuery("form"));的Chrome控制台输出:

In response to a comment here is the Chrome console output of console.log(jQuery("form"));:

E.fn.E.init
    0: HTMLFormElement
    length: 1
    prevObject: E.fn.E.init
    __proto__: Object

推荐答案

事实证明它必须是wordpress的怪癖".我从另一个插件中调用js,并使用wp_equeue_script().wp_equeue_script()在末尾添加了?ver=3.3.2,因为它不是ver 3.3.2,所以没有被加载,它被称为depsite chrome.

It turns out it must be a wordpress 'quirk'. I was calling the js from a different plugin and using wp_equeue_script() The wp_equeue_script() added ?ver=3.3.2 to the end and as it wasn't ver 3.3.2 it wasn't being loaded depsite chrome showing it as called.

这篇关于未捕获的TypeError:对象#&lt; Object&gt;没有方法“验证"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆