Use nextObj in valid event handlers to determine if validation is needed before moving to the other control. For example, the following event handler determines if the selected control is a Cancel button:

function somedata_valid( )

   if form.nextObj == form.cancelButton 

      return true // Don't bother with validation code 

   else 

      // Validate as usual 

   endif 

Note that this approach only works if the Cancel button is not the next button in the tab order. Otherwise pressing Tab would make nextObj the Cancel button, but simply tabbing to that button doesn’t mean the user will click it. In that case, you would want to validate the data. You can remove the Cancel button from the tab order so that the user must click the button or press the accelerator key for the button, which would cancel the form.