jquery-validate "object expected" error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • thj

    jquery-validate "object expected" error

    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).rea dy(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).rea dy(function()

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

    Thanks in advance.
    Tommy.
  • RobG

    #2
    Re: jquery-validate &quot;object expected&quot; error

    On Aug 14, 7:18 pm, thj <to...@holmjako bsen.dkwrote:
    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

    Comment

    • Henry

      #3
      Re: jquery-validate &quot;object expected&quot; error

      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/f....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).rea dy(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).rea dy(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.

      Comment

      Working...