开发者

How do I keep track of when what is the text entered in the form when the user navigates away from the page?

开发者 https://www.devze.com 2023-01-25 23:32 出处:网络
I have a piece of code like this. <form method=\"get\" action=\"{$self}\" name=\"addcommentform\">

I have a piece of code like this.

<form method="get" action="{$self}" name="addcommentform">
<textarea title="{$enter开发者_高级运维Comment}" name="comment" class="commentarea" </textarea>
<input class="Button" type="submit" value="{$postComment}" />
</form>

How do I keep track of when what is the text entered in the form's textarea when the user navigates away from the page? I want to prompt the user with a warning message so he/she doesn't lose the text.

Thanks.


You could use the javascript/jquery blur event, and if the user hasn't clicked the desired button have it display the form values. This might help JQuery Blur Validation Problem

Stu


Take a look at this Javascript code snippet:

http://www.boutell.com/newfaq/creating/disableclose.html

This takes advantage of the window's onbeforeunload event which fires when the user is about to leave the page.

0

精彩评论

暂无评论...
验证码 换一张
取 消