How to check that a form has been changed
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

How to check that a form has been changed

From: Taras_96 <taras.di@gmail.com>
Date: Sun Apr 30 2006 - 10:49:51 CEST

Hi everyone,

How do you detect that a form element has been changed? This thread:

http://groups.google.com/group/comp.lang.javascript/browse_thread/thread/9ae1c9d419264380/125a82c9be127790?lnk=st&q=checking+html+form++(updated+OR+edited+OR+changed)&rnum=28&hl=en#125a82c9be127790

suggests that you attach onChange event handlers to every form element,
and when the handler fires you update a global 'isChanged' variable.
This technique seems to be a bit messy to me (I have many form
elements), I was thinking about storing the original form object in a
javascript variable when the body loads (in the bodie's onLoad event
handler), and upons submission, doing a javascript equality comparison
with the current form object. If nothing has changed, then the two
objects should be equal, right?

if(oldObject == document.getElementById('form'))
{
  alert('has changed!');
}

Would this work?

Cheers

Taras
Received on Mon May 1 05:27:43 2006