www.webdeveloper.com
Results 1 to 2 of 2

Thread: Prevent form from submitting when window.onerror

  1. #1
    Join Date
    Nov 2006
    Posts
    26

    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 form.submit method from submitting data if an error is captured from the window.onerror event. Below is my code for the event.

    window.onerror = function handleError(sMessage, sUrl, sLine){
    alert("An error has occured with this application. Please take a screen shot of\nthis error and email to the help desk\n\n"
    + "Description: " + sMessage + "\n\nURL: " + sUrl + "\n\nLine Number: " + sLine);
    return true;
    }


    part of my form's code

    <form
    action="https://locationofdatabase" method="POST" name="qdbform"
    onSubmit="return validateForm(this);" onReset="return resetForm(this);">

  2. #2
    Join Date
    Nov 2002
    Location
    Baltimore, Maryland
    Posts
    12,279
    Something like:
    Code:
    window.onerror = function handleError(sMessage, sUrl, sLine){
        alert("An error has occured with this application. Please take a screen shot of\nthis error and email to the help desk\n\n" + "Description: " + sMessage + "\n\nURL: " + sUrl + "\n\nLine Number: " + sLine);
        document.forms[0].action = ''
        return true;
    }
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles