Title: Implement custom validation logic
Last modified: December 14, 2020

---

# Implement custom validation logic

 *  Resolved [raggiorama](https://wordpress.org/support/users/raggiorama/)
 * (@raggiorama)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/implement-custom-validation-logic/)
 * Hello! I’ve added a custom field following the instructions here [https://givewp.com/documentation/developers/how-to-create-custom-form-fields/](https://givewp.com/documentation/developers/how-to-create-custom-form-fields/).
 * It is a text field that should contain a fiscal code number (PAN number for Indian
   donors).
    Specifically I have a function that via regex checks if the input string
   is correct and I’d like to know which GIVE actions should I hook that function
   to, so that if the input value is not valid the form is not processed and an 
   error message appears like the one for required fields.
 * I’ve been struggling with this for a while now and any help is greatly appreciated.
   Thank you

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Contributor [Matt Cromwell](https://wordpress.org/support/users/webdevmattcrom/)
 * (@webdevmattcrom)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/implement-custom-validation-logic/#post-13787576)
 * Hi there,
 * We can help you best if you provide us with the code you’re attempting to use.
   Paste a link here to a Gist or similar and we’ll take a look.
 * Thanks!
 *  Thread Starter [raggiorama](https://wordpress.org/support/users/raggiorama/)
 * (@raggiorama)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/implement-custom-validation-logic/#post-13791018)
 * Hi Matt,
    thank you for getting back to me. I looked into the repo and found 
   a hook “give_pre_process_donation” inside inc/process-donation.php that seems
   to be working. Here’s the [link](https://gist.github.com/lauraraggi/e7ac7bf634f668048a3f774051b46339)
   to code. I tested it a few times and it seems to be working but I don’t know 
   if that’s the right place to make that check happen…
 * I also see that the error messages get printed near the form submit button: is
   there a better way to print the error messages, by using ajax perhaps? I would
   also like to avoid the error messages to be printed twice if, for example, the
   user writes two consecutive wrong PAN numbers.
 * Thank you again for your prompt reply, I appreciate it.
    Laura
 *  Plugin Contributor [Matt Cromwell](https://wordpress.org/support/users/webdevmattcrom/)
 * (@webdevmattcrom)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/implement-custom-validation-logic/#post-13810538)
 * HI there,
 * The best would be to use the hook `give_checkout_error_checks` We have a sample
   snippet here that shows how you can do custom field validations:
    [https://github.com/impress-org/givewp-snippet-library/blob/master/form-customizations/validate-donation-amount.php](https://github.com/impress-org/givewp-snippet-library/blob/master/form-customizations/validate-donation-amount.php)
 * Thanks!
 *  Thread Starter [raggiorama](https://wordpress.org/support/users/raggiorama/)
 * (@raggiorama)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/implement-custom-validation-logic/#post-13816520)
 * Thank you, Matt! That works as I intended.
    Best wishes, Laura

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Implement custom validation logic’ is closed to new replies.

 * ![](https://ps.w.org/give/assets/icon-256x256.jpg?rev=2873287)
 * [GiveWP - Donation Plugin and Fundraising Platform](https://wordpress.org/plugins/give/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/give/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/give/)
 * [Active Topics](https://wordpress.org/support/plugin/give/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/give/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/give/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [raggiorama](https://wordpress.org/support/users/raggiorama/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/implement-custom-validation-logic/#post-13816520)
 * Status: resolved