Re: 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

Re: How to check that a form has been changed

From: Matt Kruse <newsgroups@mattkruse.com>
Date: Sun Apr 30 2006 - 23:11:35 CEST

RobG wrote:
> An alternative is to go through all the form controls and test if
> their current value is the same as their default value. Where it
> isn't, they've been changed.
> How you do the test depends on the type of element. Inputs of type
> "text", "file" or "password" have a defaultValue attribute that is
> their default value, so you can test their current value against that.

This is the approach taken in my functions at
http://www.mattkruse.com/javascript/validations/source.html

I provide an isChanged() function that takes a reference to any input
control and returns true or false. It relies on generalized getInputValue()
and getInputDefaultValue() functions which work for any input type and are
also useful on their own.

There is also isFormModified() which loops through all form controls and
calls isChanged() on each and also provides a few additional features.

-- 
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Received on Mon May 1 05:28:18 2006