Editing prompt in javascript -
In my web application, I have a page with many input values, and want to confirm that the user wants to leave it The page tries to leave the user with unsaved notifications without saving (like prompting to exit Microsoft Word with unsaved changes on the document). I would like to display a custom message that "You have made changes that have not been saved. Do you really want to leave the page?" How can I go about doing this?
You change
Events on Inputs This event is not bubble, so you have to attach it individually to each input, then you need to use the window
object's beforeunload
event to signal the user Will be.
& lt; Script type = "text / javascript" & gt; Var anythingEdited = false; Function input changed () {anythingEdited = true; } Window.onbeforeunload = function (evt) {if (anythingEdited) {evt = evt ||.} Window.event; Evt.returnValue = "You have edited something. If you click OK, your changes will be lost."; }}; & Lt; / Script & gt; First name: & lt; Input type = "text" id = "first name" name = "firstname" onchange = "input-chain ();" & Gt;
Comments
Post a Comment