> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slm.m1amdocs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# onSubmitEvent: Merchant Form Validation

Because the Vindicia object takes over the Submit event when you call `vindicia.setup()`, you cannot call a validation function directly. Instead, your validation function is called for you. Specify the validation function in `vindicia.setup()` as follows:

```
onSubmitEvent: function(theForm) { 
   return merchantValidate(theForm); 
  },
```

When the user clicks the `Submit` button, `merchantValidate(theForm)` is called. You must return a boolean value. `True` causes the form to be submitted, `false` blocks submission of the form.

```

 Structure your validation function as follows:
 function merchantValidate(theform)
 {
  if (!vindicia.isValid('vin_PaymentMethod_creditCard_account'))
  {
  // sensitive field
  alert('Please enter a valid credit card before submitting');
  return false;
  }
  if (!vindicia.isValid('vin_PaymentMethod_creditCard_expirationDate'))
  { 
  // sensitive field
  alert('Please enter a valid expiration date YYYYMM before submitting');
  return false;
  }
 
  if (theform.vin_PaymentMethod_accountHolderName.value.length == 0)
  {
  // non sensitive field
  alert('Please enter the Account Name');
  return false;
  }
 
  if (vindicia.cardType == "amex" && 
vindicia.dataLength('vin_PaymentMethod_nameValues_cvn') != 4)
  {
  alert("American Express CVV must be 4 digits");
  return false
  }
  return true;
 }
```

You must return true or false.

**Parent topic:**[Implementing HOA with Hosted Fields](../topics/Implementing_HOA_with_Ho)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.