Script to test if values changed on form?

P

planetthoughtful

Hi All,

I'm wondering if anyone can point me to a javascript that will prompt a
user if they want to lose changes when they've edited one of several
fields on a form and are now navigating away from the page without
clicking submit?

If it makes any difference, the user will be viewing via Firefox 1.5 (I
know this, because I'm the user ;-).

Any help appreciated!

Much warmth,

planetthoughtful
 
R

RobG

planetthoughtful said:
Hi All,

I'm wondering if anyone can point me to a javascript that will prompt a
user if they want to lose changes when they've edited one of several
fields on a form and are now navigating away from the page without
clicking submit?

If it makes any difference, the user will be viewing via Firefox 1.5 (I
know this, because I'm the user ;-).

There is a thread here that should help:

<URL:http://groups.google.co.uk/group/co...e?q=test+form+changed&rnum=1#b093cf498a4f9f6e>
 
P

planetthoughtful

Damn - that just left me more confused. Unfortunately, when I Google I
tend to find results for form validation. Whereas, I just want to be
able to prompt if a value has been edited but not submitted.

I'll keep looking - thanks Rob.

Much warmth,

planetthoughtful
 
R

Randy Webb

planetthoughtful said the following on 5/22/2006 8:21 PM:
Damn - that just left me more confused. Unfortunately, when I Google I
tend to find results for form validation.

Did you find anything when Googling the archives about quoting what you
are replying to?

If you want to post a followup via groups.google.com, don't use the
"Reply" link at the bottom of the article. Click on "show options" at
the top of the article, then click on the "Reply" at the bottom of the
article headers.

Whereas, I just want to be able to prompt if a value has been edited
but not submitted.

That is precisely what the thread Rob pointed you to deals with - how to
tell if a form field has been changed or not. You check to see if
anything in the form has been changed. If it has, then you prompt. If it
hasn't, then you don't prompt.

Since you are wanting to check it before leaving the page, you look into
onunload of the window object.

Onsubmit of the form, you set a variable that the unload checks for. If
the form is submitted, you don't prompt.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,201
Latest member
KourtneyBe

Latest Threads

Top