/    Sign up×
Community /Pin to ProfileBookmark

Prevent form from submitting when window.onerror

I created a generic function on the <head> level of my page to capture any errors that a user may receive. Whe I am unsure of is how would I cancel the [FONT=Courier New]form.submit[/FONT] method from submitting data if an error is captured from the window.onerror event. Below is my code for the event.

[FONT=Courier New]window.onerror = function handleError(sMessage, sUrl, sLine){
alert(“An error has occured with this application. Please take a screen shot ofnthis error and email to the help desknn”
+ “Description: ” + sMessage + “nnURL: ” + sUrl + “nnLine Number: ” + sLine);
return true;
}[/FONT]

part of my form’s code

[FONT=Courier New]<form
action=”https://locationofdatabase” method=”POST” name=”qdbform”
onSubmit=”return validateForm(this);” onReset=”return resetForm(this);”>[/FONT]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@CharlesNov 13.2006 — Something like:window.onerror = function handleError(sMessage, sUrl, sLine){
alert("An error has occured with this application. Please take a screen shot ofnthis error and email to the help desknn" + "Description: " + sMessage + "nnURL: " + sUrl + "nnLine Number: " + sLine);
[b]document.forms[0].action = ''[/b]
return true;
}
×

Success!

Help @daniboi81 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.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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