OnChange Event

Results 1 to 2 of 2

Thread: OnChange Event

  1. #1
    David Borland Guest

    Default OnChange Event

    Is there anyway to get the onchange event to always fire? I have a screen that is made up of several frames. I have onchange event handlers to verify that the user has entered valid data into text fields and if they have not, I cancel the onchange event and keep them on the current field.<BR><BR>This works correctly as long as I am going to another field on the same frame. But if I click on another frame, the onchange event does not fire and the focus moves to the new frame. Thus invalid data is left in data field.<BR><BR>What is the best way to get this to work? I tried doing my checking on the onblur event since that always fires (if it&#039s invalid place I place the focus back on the current field), but since I also display a warning alert box, that puts me in an endless loop. I could display the message in the status bar but like popping up a message.<BR><BR>I&#039m developing for IE 4 and 5.<BR><BR>Thanks. David

  2. #2
    Join Date
    Dec 1969

    Default RE: OnChange Event

    onBlur is the basic solution. Then you *also* keep track of whether or not you have done the alert for this particular field and don&#039t do it a second time.<BR><BR>How do you keep track? Easiest solution is probably to keep track of (1) where the last onBlur came from (if you use a generic routine...not needed if you have a separate event handler for each form field) and (2) what the contents (.value) of the field were last time the onBlur fired. <BR><BR>If you get the same contents from the same onBlur event, skip the check and skip the alert.<BR><BR>I know it&#039s hokey, but I, too, had to do something like this when I was using multiple frames. <BR><BR>p.s.: Netscape was worse. I forget the details now, but I remember having to put in even more code to handle its foibles.<BR><BR>Bill Wilkinson<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts