Generate an object checksum (or alternative?)
Posted: Mon Sep 18, 2006 3:22 pm
When my page loads it has some dynamic (generated client side) form elements in it. I'm too lazy to go through checking exactly what the dynamic content is and I just need to know if it gets modified in anyway after the page loads so I wanted some quick way of doing something like generating a checksum of the object's state when the page loads and then generating another one before the page is left (a new form submission). If the two checksums match the dynamic content was left untouched by the user; if they don't match the user changed something.
I tried using a recursive clone() function to copy the element at page load and then compare it with the real element at the end but they always prove to be different even when nothing gets modified so that doesn't work for me
Just need something like:
I *could* go through everything and figure it all out but the amount of logic needed would be lots.
I know it's a dirty hack but does anybody have any clues if this might be possible? Or something similiar?

I tried using a recursive clone() function to copy the element at page load and then compare it with the real element at the end but they always prove to be different even when nothing gets modified so that doesn't work for me
Just need something like:
Code: Select all
originalChecksum = checksum(document.getElementById('my_id'));
//User does whatever
if (checksum(document.getElementById('my_id')) != originalChecksum)
{
alert('You modified the form');
}
I know it's a dirty hack but does anybody have any clues if this might be possible? Or something similiar?