At the top of the function, you're comparing the field value against
''; but at the bottom if they cancel their change, you're setting it
to this._txtFld.  Should the comparison at the top be against
this._txtFld?  Or should a confirmed change set this._txtFld?  Not
that that would explain it was working in FF and not IE, unless the
testing was done differently.  I'm not seeing an issue with 'change'
not being fired, either on IE6 or IE7.

If that's not it, I'd try picking up with step #3 from this article on
the unofficial wiki:

BTW, on the focus thing:  You'll probably find that the focus doesn't
shift back to the field if you call focus() from within the change
handler; deferring the call might help, something like this after
resetting the value (don't forget to add a var at the top for

    field = e.findElement(); // The 1.6 way of doing Event.element(e)

T.J. Crowder
tj / crowder software / com
Independent Software Engineer, consulting services available

On Jan 22, 9:39 pm, "J. Gregory Wright" <daecab...@gmail.com> wrote:
> So, I have a simple bit of code that asks a user to confirm that they
> want to change the existing value of a text field:
> <code>
> ...
> Event.observe(this._form['txtFld'], 'change',
> this.txtFldChanged.bindAsEventListener(this), false);
> this._txtFld = this._form['txtFld'].value;
> ...
> function txtFldChanged(e)
> {
>   var confirmed = (this._txtFld == '');
>   if (! confirmed)
>   {
>     confirmed = confirm('Are you sure you want to change the value of
> txtFld?');
>   }
>   if (! confirmed)
>   {
>     this._form['txtFld'].value = this._txtFld;
>     Event.element(e).focus();
>   }
>   return confirmed;}
> </code>
> In FF, this works fine, every time you edit the content of the field.
> In IE, it works once - after that the change event does not fire. I've
> seen some mention of a possible behavior issue in IE having to do with
> modification of the text field value programmatically within the event
> bubble for the field's change event, but nothing concrete.
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to