0

i'm just using the JQuery validation plugin. i have the following spec: 'if the form isn't used in 10 seconds, give the user a warning, if he doesn't do anything, submit it anyway'

besides the timer etc. i have this code to submit the form:

timeoutId = setTimeout(function() {

$("#session_expired").val("true");
$("form:first").validate({
                    onsubmit: false
                });
$("form:first").submit();
}, 10000);

what it does: it sets a certain hidden field value and then it submits the form. I've added the validate function to make sure it doesn't validate in this case. Bu you might have guessed it: it doesn't work.

Anyone any clue?

Michel

1
  • good one :) it doesn't submit, it still marks all the required fields with no value as 'invalid' and it doesn't submit Commented Nov 12, 2009 at 10:29

2 Answers 2

1

Try using the DOM method directly instead of jQuery submit method for the submit:

Replace

$("form:first").submit();

with:

document.forms[0].submit();

My guess is that:

$("form:first").validate({ onsubmit: false });

only applies to when the form is submited by a submit button push.

Sign up to request clarification or add additional context in comments.

1 Comment

i THINK that is a good guess (i'm not sure) but i KNOW this works. Thanks!
0

I would remove each part of the function and then test it until I can find which part of the function is a failing. Also us firebug and console.log to trace what is happening within the function. e.g.

timeoutId = setTimeout(function() {
console.log('timeout')
}, 10000);

1 Comment

it does fire the function ($("form:first").submit();) after 10 seconds, but the validation doesn't 'stop' so i'm thinking maybe the $("form:first").validate({ onsubmit: false }); isn't correct

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.