Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

onblur, onchange, button clicked

 
gino jersey
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why don't you just change onblur to onchage?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic