/    Sign up×
Community /Pin to ProfileBookmark

Confirm box return focus if cancel

I have a form that if they do not select something in particular I want a confirm box to remind them they did not fill it out. if they hit OK then post form anyway. If they choose cancel, I want to not post form but place focus back on the main window so they can fill it out.

I did a search for this already within this forum but I cannot seem to find anything on it.

Thanks for your help with this.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@SelrachJan 20.2006 — you can set focus to the element desired and then return false on cancel.
[CODE]function confirmSubmit(){
if(document.getElementById("idOfElementToCheck") != something){
var yorn = confirm("Something isn't filled, do you still want to submit?");
if(!yorn) {
document.getElementById("idOfElementToFocusOn").focus();
return false;
}
return true;
}
}[/CODE]
Copy linkTweet thisAlerts:
@tripwaterauthorJan 20.2006 — Thank you for your time. That worked!!!
×

Success!

Help @tripwater spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...