onblur function interrupting form submission

J

josh.dutcher

I'm trying to set up a simple "change your password" form. I've got an
AJAX process that is checking the new password the user enters against
their current password to make sure they're changing it. This function
is firing via the password field's onBlur event handler.

I want to do some other form validation using the form's onSubmit
handler (onSubmit="return validateForm();", and if all those conditions
are met, the form submits.

Problem is, if focus is on that password field and the user attempts to
click the submit button, the onBlur event fires, and after that,
nothing happens. The flow seems to be interrupted - I get no further
activity indicating the click happened. No onFocus for the submit
button, no onClick for that button, no onSubmit events will fire, and
the form does not submit.

How do I continue the process beyond that onBlur function if the user
is trying to click the submit button?

Thanks in advance.
 
W

web.dev

I'm trying to set up a simple "change your password" form. I've got an
AJAX process that is checking the new password the user enters against
their current password to make sure they're changing it. This function
is firing via the password field's onBlur event handler.

If the user has javascript disabled, what happens then? Do you do any
server-side validation?
I want to do some other form validation using the form's onSubmit
handler (onSubmit="return validateForm();", and if all those conditions
are met, the form submits.

Problem is, if focus is on that password field and the user attempts to
click the submit button, the onBlur event fires, and after that,
nothing happens. The flow seems to be interrupted - I get no further
activity indicating the click happened. No onFocus for the submit
button, no onClick for that button, no onSubmit events will fire, and
the form does not submit.

How do I continue the process beyond that onBlur function if the user
is trying to click the submit button?

Here's a scenario, let's just say that the server is under heavy
traffic, when the user submits the form, will your "AJAX" request come
back fast enough? Instead, I would say to keep your current validation
done through the onsubmit event handler and do the password checking on
the server-side. An even more plus is to do form validation on the
server-side as well, in case the user has turned off javascript.
 
J

josh.dutcher

When the AJAX process begins, I have a "message" area that is changed
to read "checking..." along with an animated spinning hourglass,
windows-mouse-cursor-style.

And yes, I'm doing server-side validation as well.

Yes, you're right, I could do all this server-side. At this point it's
the principle - there's got to be a way to do this, so know I'm curious
what it is.
 
R

Randy Webb

(e-mail address removed) said the following on 2/6/2006 5:14 PM:
I'm trying to set up a simple "change your password" form.

Then have one. They are easy.
I've got an AJAX process that is checking the new password
the user enters against their current password to make sure
they're changing it.

That is, without a doubt, the dumbest way to achieve it.
This function is firing via the password field's onBlur event handler.

That is almost, but not quite, dumber than the "AJAX Process".

Use the onchange, not the onblur
I want to do some other form validation using the form's onSubmit
handler (onSubmit="return validateForm();", and if all those conditions
are met, the form submits.

Then do it.
Problem is, if focus is on that password field and the user attempts to
click the submit button, the onBlur event fires, and after that,
nothing happens.

Flaw in your reasoning. Have your magical "AJAX Process" disable the
submit button.....
The flow seems to be interrupted - I get no further
activity indicating the click happened. No onFocus
for the submit button, no onClick for that button, no
onSubmit events will fire, and the form does not submit.

Welcome to the Web.
How do I continue the process beyond that onBlur function if the user
is trying to click the submit button?

Read above.
 
R

Randy Webb

(e-mail address removed) said the following on 2/6/2006 5:35 PM:

Please quote what you are replying to.

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.
When the AJAX process begins,

No, when you *hope* it begins. It may not even be supported (and it's
not in some browsers).
I have a "message" area that is changed
to read "checking..." along with an animated spinning hourglass,
windows-mouse-cursor-style.

Does it have anything in that message about quoting what you are
replying to in Usenet? It should.
And yes, I'm doing server-side validation as well.

As you should - always.
Yes, you're right, I could do all this server-side.

And doing it client-side is nothing but a mere convenience to the user
who decides to allow it to happen.

At this point it's the principle - there's got to be a way to do this,
so know I'm curious what it is.

The Genie in the bottle has the solution. Reply to my other reply to you
and you might get an answer (it is in the other reply).
 
L

Lee

(e-mail address removed) said:
When the AJAX process begins, I have a "message" area that is changed
to read "checking..." along with an animated spinning hourglass,
windows-mouse-cursor-style.

And yes, I'm doing server-side validation as well.

Yes, you're right, I could do all this server-side. At this point it's
the principle - there's got to be a way to do this, so know I'm curious
what it is.

You should never trigger server side processing onblur.
There are far too many things that can accidentally cause the
focus to change. Pre-submission validation should be for the
convenience of the user, not a way of tormenting them.
 

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

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,737
Latest member
Georgeengab

Latest Threads

Top