By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,604 Members | 858 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,604 IT Pros & Developers. It's quick & easy.

Javascript form elements defaultstate

P: n/a
Hi ,

Is there some way by which I get to know if the state of my form
elements have changed or not ? I mean If I have to save data which has
been entered by user in the screen, Is there some way in the JS level
that I am able to check (before i pass information to java) if the
value of the form element is same or different from the time the page
had loaded ?

So ill be able to selelct and save only those elements whose values
have been changed

I am dealing with text boxes and drop downs . .

thanks

Jan 9 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You can check defaultValue/defaultChecked value of element.

if(elem.defaultValue != elem.value) {
//elem value is changed.
}

Jan 9 '06 #2

P: n/a
ms*****@gmail.com wrote:
Is there some way by which I get to know if the state of my form
elements have changed or not ?
My lib at http://www.JavascriptToolbox.com/validations/ has an isChanged()
function which can tell you if an input of any time has been changed from
its initial state.
So ill be able to selelct and save only those elements whose values
have been changed


This is not a good idea.
Instead, submit everything, and have your server-side code check against
what is already in the database and save only the changed items.
Marking fields as 'dirty' on the client side works, but ultimately is not as
bullet-proof as handling all that logic on the server side.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Jan 9 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.