jquery-validate "object expected" error

T

thj

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

RobG

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

Henry

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top