开发者

Microsoft JScript runtime error: Object doesn't support property or method 'validate'

开发者 https://www.devze.com 2023-04-11 05:21 出处:网络
This issue is that i am getting the error, Microsoft JScript runtime error: Object doesn\'t support property or method \'validate\'. Couldn\'t figure out why. Any suggestions?

This issue is that i am getting the error, Microsoft JScript runtime error: Object doesn't support property or method 'validate'. Couldn't figure out why. Any suggestions?

<form id="ContactUs" class="float-left" autocomplete="off">
    <div class="box-content">
            <div id="Department-List" class="field clearfix">            
                <select id="DepartmentList" size="1" name="DepartmentList" class="required">
                   <% foreach(var options in (List<string>)ViewBag.DepartmentList) { %>
                        <option id="<%:options%>" value="<%:options%>" ><%:options%></option>
                    <% } %>
                </select>
            </div>
            <div class="field clearfix">
                <label class="float-left">NAME:</label>
                <input type="text" id="Name" class="required full-width text radi-4" minlength="3"/>
            </div>
            <div class="field clearfix">
                <label class="float-left">PHONE:</label>
                <input type="text" id="Phone" class="required PhoneNumbers full-width text radi-4" />
            </div>
            <div class="field clearfix">
                <label class="float-left">EMAIL:</label>
                <input type="text" id="SendersEmail" class="required email full-width text radi-4"/>
            </div>
            <div class="field clearfix">
                <label class="float-left">ACCOUNT #:</label>
                <input type="text" id="AccountNumber" class="full-width text radi-4" />
            </div>
            <div class="field clearfix">
                <label class="float-left">QUESTIONS:</label>
                <textarea id="QuestionBox" rows="4" cols="25" class="required full-width text radi-4"></textarea>
            </div>


            <div class="field clearfix">
                <input id="submit-inventory-request-button" type="submit" name="Submit" value="Send" class="submit next-step toggle-btn radi-3 arrow-icon" />
            </div>

When I am trying to submit the form I am getting the error from $('#ContactUs').validate() function.

 <script type="text/javascript">

     $(document).ready(function () {
         $('#ContactUs').validate({
            errorElement: 'span',
            success: 'valid',
         开发者_如何学编程   error: 'error',
            submitHandler: function() {

                var contact = {
                    DepartmentList: $('#DepartmentList').val()
                        , Name: $('#Name').val()
                        , Phone: $('#Phone').val()
                        , SendersEmail: $('#SendersEmail').val()
                        , RequestersEmail: $('#RequestersEmail').val()
                        , AccountNumber: $('#AccountNumber').val()
                        , QuestionBox: $('#QuestionBox').val()
                        , TermsCheckBox: $('#TermsCheckBox').val()
                };
                var req;
                req = DT.ajaxData('/Ajax/ContactUs/', 'POST', JSON.stringify(contact));

                // if the ajax request is successful, then display the success message and redirect the page
                req.done(function(data) {
                    console.log(data);
                    $("#partial").dialog('close');
                    $("#SuccessMessage").dialog({ buttons: { "Ok": function() { $(this).dialog("close"); } } });
                });

                return false;

            }
        });
    })


There is no built-in jQuery function named validate. It's available from several plugins though. For example

  • http://docs.jquery.com/Plugins/Validation

Have you properly included the plugin's in your page?


If using Visual Studio the simplest way is to use the NuGet extension to download jQuery. If you don't have it you can find it at www.codeplex.com and install it. Then go to Tools -> Library Package Manager -> Manage NuGet Packages within Visual Studio and search for jQuery. Once this is installed, the Script folder within your project will have the required files.

Modify the path within your view.cshtml file to point to the current version of jQuery e.g 1.7.1 in this case

0

精彩评论

暂无评论...
验证码 换一张
取 消