jquery-validate "object expected" error

Discussion in 'Javascript' started by thj, Aug 14, 2008.

  1. thj

    thj Guest

    Hi.

    I've got this form that I'm trying to validate:

    <form id="periodForm" action="" method="post">
    <p>
    Periode:
    <input id="startDate" name="startDate" type="text" size="7"
    value="<%= ViewData["StartDate"] %>" />
    -
    <input id="endDate" name="endDate" type="text" size="7"
    value="<%= ViewData["EndDate"] %>" />
    <input id="submit" type="submit" value="Search" />
    </p>
    </form>

    With the following jquery-validate code:
    <script type="text/javascript">
    $(document).ready(function()
    {
    $("#periodForm").validate(
    {
    rules:
    {
    startDate: "required",
    endDate: "required"
    },
    messages:
    {
    startDate: "Skal angives",
    endDate: "Skal angives"
    }
    });
    });
    </script>

    When I'm pushing the submit button, the page reloads, and I get the
    error "Object expected", on the line:
    $(document).ready(function()

    I've double checked everything, and can't find any errors - could you
    please help me out here?

    Thanks in advance.
    Tommy.
     
    thj, Aug 14, 2008
    #1
    1. Advertising

  2. thj

    RobG Guest

    On Aug 14, 7:18 pm, thj <> wrote:
    > Hi.
    >
    > I've got this form that I'm trying to validate:

    [...]
    > With the following jquery-validate code:

    [...]
    > I've double checked everything, and can't find any errors - could you
    > please help me out here?


    Ask in a jQuery group.


    --
    Rob
     
    RobG, Aug 14, 2008
    #2
    1. Advertising

  3. thj

    Henry Guest

    On Aug 14, 10:18 am, thj wrote:
    > Hi.
    >
    > I've got this form that I'm trying to validate:
    >
    > <form id="periodForm" action="" method="post">
    > <p>
    > Periode:
    > <input id="startDate" name="startDate" type="text" size="7"
    > value="<%= ViewData["StartDate"] %>" />
    > -
    > <input id="endDate" name="endDate" type="text" size="7"
    > value="<%= ViewData["EndDate"] %>" />
    > <input id="submit" type="submit" value="Search" />

    ^^^^^^ ^^^^^^
    Naming a submit button "submit" has the consequence of rendering the -
    submit - method of forms unusable. None of the code you have posted
    attempts to use the - submit - method, but that does not mean you
    should get into the habit of using such names (see:-

    <URL: http://jibbering.com/faq/faq_notes/form_access.html#faComMis >

    ), and it does not mean that the code not posted does not attempt to
    use the - submit - method of the form. Although the error "object
    expected" usually means that IE is attempting to execute a function
    but the Identifier for the function did not resolve as an object (and
    therefore not a function object, which is has to be if it is to be
    called).

    And the error message IE usually produces if you do attempt to use the
    - submit - method of a form that has been replaced by an Element
    reference is "Object doesn't support this property or method" (i.e. it
    is an object but it does not support being called; it is not a
    function object).

    > </p>
    > </form>
    >
    > With the following jquery-validate code:
    > <script type="text/javascript">
    > $(document).ready(function()
    > {
    > $("#periodForm").validate(
    > {
    > rules:
    > {
    > startDate: "required",
    > endDate: "required"
    > },
    > messages:
    > {
    > startDate: "Skal angives",
    > endDate: "Skal angives"
    > }
    > });
    > });
    > </script>
    >
    > When I'm pushing the submit button, the page reloads,


    But does the validation happen before the page "reloads"?

    > and I get the
    > error "Object expected", on the line:
    > $(document).ready(function()


    So this error does not occur the first time the page loads, only when
    it is re-loaded following form submission? That seems very unlikely (I
    realise that JQuery is badly enough written that inconsistent
    behaviour is likely from it, but that line is the entry point, before
    JQuery has really gotten going, so it should be consistent).

    Incidentally, form validation is probably the one area of browser
    scripting where it really is easy to write a one-code-fits-all system,
    so why are you involving JQuery in the process and sacrificing all
    that cross-browser compatibility?

    > I've double checked everything, and can't find any
    > errors - could you please help me out here?


    Probably, but the odds are that you will never provide sufficient
    context information or any sort of demonstration of the phenomenon.
     
    Henry, Aug 14, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kiyomi

    Object Expected error

    Kiyomi, Jan 6, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    11,250
    Kiyomi
    Jan 10, 2006
  2. =?Utf-8?B?R3JlZw==?=
    Replies:
    4
    Views:
    5,858
    sirfunusa
    Apr 5, 2006
  3. Steve Chapel
    Replies:
    15
    Views:
    245
  4. Aaron Gray
    Replies:
    20
    Views:
    403
    Lasse Reichstein Nielsen
    Jul 27, 2008
  5. lorlarz
    Replies:
    6
    Views:
    214
    David Mark
    Mar 25, 2010
Loading...

Share This Page