I have a popup form with 4 textboxes, all of which have default values when the page loads.
Here’s the scenario… The user has filled in the form with their details but decides not to submit the form and closes the popup. I want the values of the textboxes to revert to their default values when the user close the popup.
Here’s my code so far.
$(".close").click( function() {
$(".popup").find("input").val("Default value of textbox");
});
Rather than inserting “Default value of textbox” as the value, I want it to be the actual default value.
You could put the default values in a ‘data attribute’ on the elements themselves…I’ll create a fiddle to show this… As seen in this jsFiddle
I should also note that you can put the data attribute on the elements from the server…I’m just showing how you could do it all from the client…