【发布时间】:2013-01-16 23:16:54
【问题描述】:
我使用 javascript 函数和“window.beforeunload”属性来检查用户在离开页面之前是否对我的 Web 表单进行了任何更改。在此函数中,我将文本字段的 defaultValue 与值进行比较。但是,我在表单中添加了两个 ListBox,而 defaultValue 方法对它们不起作用。我可以用什么来代替 Selects?
文本字段示例:
if(document.forms['form2']['itemID'].value != document.forms['form2']['itemID'].defaultValue)
{return 'There are unsaved changes in the form!'}
【问题讨论】:
-
USE defaultSelected for Select box.... 见这个链接:w3schools.com/jsref/prop_option_defaultselected.asp
-
@Pandian: w3fools。糟糕的网站就是糟糕的。
标签: javascript forms