Connecting Tech Pros Worldwide Help | Site Map

onblur function interrupting form submission

  #1  
Old February 6th, 2006, 10:25 PM
josh.dutcher@gmail.com
Guest
 
Posts: n/a
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.

  #2  
Old February 6th, 2006, 10:35 PM
web.dev
Guest
 
Posts: n/a

re: onblur function interrupting form submission



josh.dutcher@gmail.com wrote:[color=blue]
> 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.[/color]

If the user has javascript disabled, what happens then? Do you do any
server-side validation?
[color=blue]
> 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?[/color]

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.

  #3  
Old February 6th, 2006, 10:45 PM
josh.dutcher@gmail.com
Guest
 
Posts: n/a

re: onblur function interrupting form submission


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.

  #4  
Old February 6th, 2006, 11:15 PM
Randy Webb
Guest
 
Posts: n/a

re: onblur function interrupting form submission


josh.dutcher@gmail.com said the following on 2/6/2006 5:14 PM:[color=blue]
> I'm trying to set up a simple "change your password" form.[/color]

Then have one. They are easy.
[color=blue]
> 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.[/color]

That is, without a doubt, the dumbest way to achieve it.
[color=blue]
> This function is firing via the password field's onBlur event handler.[/color]

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

Use the onchange, not the onblur
[color=blue]
> 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.[/color]

Then do it.
[color=blue]
> 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.[/color]

Flaw in your reasoning. Have your magical "AJAX Process" disable the
submit button.....
[color=blue]
> 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.[/color]

Welcome to the Web.
[color=blue]
> How do I continue the process beyond that onBlur function if the user
> is trying to click the submit button?[/color]

Read above.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
  #5  
Old February 7th, 2006, 01:55 AM
Randy Webb
Guest
 
Posts: n/a

re: onblur function interrupting form submission


josh.dutcher@gmail.com 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.
[color=blue]
> When the AJAX process begins,[/color]

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

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

As you should - always.
[color=blue]
> Yes, you're right, I could do all this server-side.[/color]

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

[color=blue]
> 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.[/color]

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

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Closed Thread