Can't you use change()?

>From the jquery docs.

"The change event fires when a control loses the input focus and its
value has been modified since gaining focus."

$("form Input, form select").change(function(){
   alert($(this).val());
});

If you want to detect the value before lost focus, you have to use
keyup event.

//The script is not tested

$("form Input, form select").each(function(){
  var origVal = $(this).val();
  $(this).keyup(function(){

  // you may want to compare the new value with the orig value from 0
to nth position
  if ($(this).val() != origVal)
      alert($(this).val());
});
});

On Aug 23, 1:42 pm, André Hänsel <an...@webkr.de> wrote:
> Hi,
>
> is there any event that I can use to trigger an action immediately
> when a form element is changed? (And similarily when it is changed and
> then looses the focus.)
>
> I think JS does not provide such an event but maybe jQuery provides
> some kind of "virtual event" for this case?
>
> Regards,
> André

Reply via email to