Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 11. Forms and Form Elements > Submitting and Prevalidating Forms

11.4. Submitting and Prevalidating Forms

In an ordinary HTML document, we submit a form by clicking on a submit button; the browser then gathers up the values we entered or selected with the input controls and sends them to the specified URI. JavaScript lets us intercept that submit request, validate the input or do whatever else we need to do, and then either permit the form submission to proceed or cancel it so that we can guide the user to improve the input.

You can perform this sort of last-second validation of data or other scripting (for example, changing the form's action property based on user choices) in a function invoked by the form's onsubmit event handler. We'll go into substantial detail about validation routines in Chapter 46, "Data-Entry Validation," on the CD-ROM. For now, we just want to show you how the onsubmit event handler works.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint