Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   jquery-validate "object expected" error (http://www.velocityreviews.com/forums/t936809-jquery-validate-object-expected-error.html)

thj 08-14-2008 09:18 AM

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).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.

RobG 08-14-2008 10:52 AM

Re: jquery-validate "object expected" error
 
On Aug 14, 7:18*pm, thj <to...@holmjakobsen.dk> 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

Henry 08-14-2008 11:04 AM

Re: jquery-validate "object expected" 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).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.


All times are GMT. The time now is 11:39 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.