aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes onblur, onchange, button clicked Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "onblur, onchange, button clicked" Watch "onblur, onchange, button clicked" New topic
Author

onblur, onchange, button clicked

gino jersey
Greenhorn

Joined: May 24, 2005
Posts: 21
I have a JSP page I'm trying to debug. Let me explain briefly.

There's a form, with text input fields in a grid (several rows) for account numbers.
There are also several buttons in the form, of interest is what is called in the app as the Approve button.

The way it was built, after a user enters a value in the account_number input field, the onblur event calls a funciton to do some validation.
That works when the user tabs out of the field.

The problem is this. If a user enters a value, and DOES not tab out of the field, but instead clicks the Approve buttons the onblur event is not executed. The validation is then bypassed.

I don't know why onblur event is not triggered when user clicks Approve, but it is when a user tabs out.
Anyone know why that is?


We have an onclick event with the Approve button, but prior to performing that, we want the data validation first performed, which is "tied" to the onblur event.

One thing that may work is the onchange event for the text input field. I put some displays and it seems to trigger that event, both when I tab out of the field, and when I click the button.

I was going to use: onchange ="foo()"

Is there a way in javascript to find out if the Approve button was clicked. Something like:
function foo() {
if Approve_button clicked, then do something....

}

Thanks.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Can;t you just trigger the validation in the approve click also? Call the function and have it return a boolean value. If false do not process the rest of the way.

You can try to combine both onchange and onblur.

Eric
gino jersey
Greenhorn

Joined: May 24, 2005
Posts: 21
It's not easliy done. It was badly designed in the first place.

This is an accounting app.
Users could enter up to N number of account numbers and amounts.
The initial design was after user enters an account number, trigger the validation before they go to another line in the grid.

They did not design it such that 1 click of the approve button validates all the grid at once.

It will take a while to redesign it. Due to time constraints we dont have time and resources to do that now.
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
why don't you just change onblur to onchage?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: onblur, onchange, button clicked
 
Similar Threads
TabIndex problem using JSF and Ajax4jsf for ajax request
TabIndex problem using JSF and Ajax4jsf for ajax request
issue with onblur and onClick
Javascript submit problem
Design help