Case is I want to prompt a message (Do you want to save changes?) if multiline text box default value is updated on .aspx page before submitting the page. I am using .text() to compare with .val().
It works fine in firefox. .text() shows the default value in firefox but in IE7 and 8 .text() shows updated value (like .val()).
if ($("#<%=txt1.ClientID%>").attr("value") === $("#<%=txt1.ClientID%>").text())
return(true);
return confirm('Do you wish to save these changes?');
jQuery doesn’t give you any special function to access the
defaultValueproperty, so you’d have to use the DOM property directly:(Works for normal text
<input>as well as<textarea>.)However note that the
defaultValueis the initial value of the field in the HTML source. If the page loaded with different content in the field, typically because you have gone to the next page and then hit ‘Back’, thedefaultValuewill still be the original value and so if you click again you’ll get the changed-warning again even though you haven’t touched it since going ‘Back’.