run a javascript form onsubmit on an aspx page

Posted on 2005-05-06
Last Modified: 2008-03-17
I have an html page with client-side javascript that calls a forms OnSubmit event (<form onsubmit="return ValidateForm(this);" action="">). ValidateForm(this) sets in motion a bunch of other javascript code after validation. However, I now need to move this form into an aspx page in order to take advantage of aspx layout and a bunch of controls for layout purposes. Now of course, when I click on my submit button, it causes postback, which I don't want.

How do I disable postback so that the client-side code in the form OnSubmit can run, or rather, display (as the results of it are not displayed because of the postback - it's as if the code had never run)?


Question by:ovalsquare
    LVL 23

    Accepted Solution

    LVL 5

    Author Comment

    I actually ended up just putting it in a button onclick event, and then accessed the form values from within the code, but jensfiederer's solution I wasn't aware of before, so will squander hard earned points on you 'cause I might use in future ;-)


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now