admin管理员组文章数量:1287608
Is there a ready-made way (maybe in one of the frameworks) to detect whether a form has changed pared to its original values?
The onchange event won't do, because it fires regardless of actual change (I could for example tick a checkbox on, and off again, with two onchange events).
The last resort would be to store each element's original value in a hidden field, and go through each one. If there is a faster method, I'd be happy to hear about it!
Is there a ready-made way (maybe in one of the frameworks) to detect whether a form has changed pared to its original values?
The onchange event won't do, because it fires regardless of actual change (I could for example tick a checkbox on, and off again, with two onchange events).
The last resort would be to store each element's original value in a hidden field, and go through each one. If there is a faster method, I'd be happy to hear about it!
Share Improve this question edited Dec 29, 2011 at 14:54 Rob W 349k87 gold badges807 silver badges682 bronze badges asked Nov 24, 2009 at 3:01 PekkaPekka 450k148 gold badges985 silver badges1.1k bronze badges 2- 2 See stackoverflow./questions/598951/… – Crescent Fresh Commented Nov 24, 2009 at 3:03
- Cheers, serializing was the new idea I was looking for. – Pekka Commented Nov 24, 2009 at 3:25
2 Answers
Reset to default 11I'm not aware of any DOM event that detects changes made to children/descendant elements' value attributes, but it should be enough to pare the serialized values before/after, $('form').serialize()
. I apologize if you already knew about this method specifically, I'm assuming you're manually going through form elements and appending values to a string.
I'm hunting for the same answer - here's the best potential solution I've e across (but haven't tried it yet): http://www.codingforums./showthread.php?t=29410&highlight=form+dirty
本文标签: javascriptDetect actual form changeStack Overflow
版权声明:本文标题:javascript - Detect actual form change? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741315306a2371877.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论