Call Function Only Once

I have a a submit button that when clicked does the following:

  1. Runs a func called getCartValues() that gathers data
  2. Validates some input text fields
  3. Sends variables to a PHP script

Since the input field validation might catch a problem the user will have to resubmit after making changes. The problem is, getCartValues() increments the data if it gets run more than once, so I need it to run only the first time the submit button is clicked and not on the following clicks. Anyone know how to code this?