Title: Validation Hook?
Last modified: September 1, 2016

---

# Validation Hook?

 *  [Martin Blumenfeld](https://wordpress.org/support/users/monkeypress/)
 * (@monkeypress)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/validation-hook-1/)
 * We have a username field that we already make an ajax call on field blur to validate
   that the user has selected a valid username and they didn’t choose a duplicate.
   Do you have an javascript hook we could plug into, so your validation would call
   our event and then wait for a valid/invalid response with an error message? Or
   maybe give us the ability to disable your real time validation on a particular
   field?
 * In the advanced form field settings you have the “Validate Real Time Input”, 
   which makes me think if I had that unchecked, it would skip validation on a particular
   field, but it doesn’t. Maybe that label needs to be renamed to “Advanced Real-
   Time Input Validation” or something along those lines.
 * [https://wordpress.org/plugins/real-time-validation-for-gravity-forms/](https://wordpress.org/plugins/real-time-validation-for-gravity-forms/)

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

 *  Plugin Author [Daman Jeet](https://wordpress.org/support/users/djeet/)
 * (@djeet)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/validation-hook-1/#post-7478305)
 * Hi Martin,
 * You had raised couple of questions.Here are my responses to them one by one:
 * 1) As of now we don’t have JS validation hooks.Unlike PHP , JS is async in nature
   which ups the level of the problem.We will think through this more thoroughly
   and incorporate it later on.
 * 2) Having said that , here is a way to achieve the solution. After your script
   has AJAX response, use below snippet to let our script trigger the validation
   message you want to show:
 * [https://gist.github.com/djeet/efbd4e6a6e875f12b192035d1a8f6797](https://gist.github.com/djeet/efbd4e6a6e875f12b192035d1a8f6797)
 * 3) To answer ” maybe give us the ability to disable your real time validation
   on a particular field” , let me explain explain hierarchy of features:
 *  A. At top is toggle switch which lets you enable real time validation on form
   level for all fields.
 * B.At next level we have validation for “Required”. This kicks in real time once
   real time validation is “Enabled”
 * C. At third layer we have Regex based validation which can be selected to enable
   even more advanced regex based validations.
 * Now it would be confusing for user ( and end user) to disable a particular field
   from realtime.
 * Imagine we have two fields in a form:
 * Field 1 (which has realtime enabled and required)
    Field 2( which has realtime
   disabled and required)
 * Submit
 * Suppose user goes into Field 1 and focuses out. In this case error for required
   will trigger on Field 1 ( as realtime is enabled) .Right?
 * Now user presses Submit. ( Note: Field 2 is still empty)
 * He would see “This field is required” message on Field 2. This would really surprise
   him and make him think “Why did the form not show me this message for Field 2
   while i did get rejection notice for Field 1?”
 * Trick is not to surprise user 🙂
 * 4) However I do agree that “Validate Real Time Input” should be been better worded
   to may be say ” Advanced Input Validation (via Regex)”
 * Hope this will solve your queries.
 * Thanks
    Jeet
 *  Thread Starter [Martin Blumenfeld](https://wordpress.org/support/users/monkeypress/)
 * (@monkeypress)
 * [9 years, 11 months ago](https://wordpress.org/support/topic/validation-hook-1/#post-7478407)
 * The way I see the javascript hook working, is that I could enter an event name
   in the field setting. In my case it would be “unique_username_result” or something
   similar. Then when you run the validation on that particular field, you could
   run the required validation first. If that passes and the field has that event
   name, then you would wait for that event to be triggered before ultimately adding
   the final valid, invalid class to the field.
 * Thanks for the validation trigger snippet. My above comment would apply to the
   other two items.

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

The topic ‘Validation Hook?’ is closed to new replies.

 * ![](https://ps.w.org/real-time-validation-for-gravity-forms/assets/icon-256x256.
   jpg?rev=1472411)
 * [Real Time Validation for Gravity Forms](https://wordpress.org/plugins/real-time-validation-for-gravity-forms/)
 * [Support Threads](https://wordpress.org/support/plugin/real-time-validation-for-gravity-forms/)
 * [Active Topics](https://wordpress.org/support/plugin/real-time-validation-for-gravity-forms/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/real-time-validation-for-gravity-forms/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/real-time-validation-for-gravity-forms/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Martin Blumenfeld](https://wordpress.org/support/users/monkeypress/)
 * Last activity: [9 years, 11 months ago](https://wordpress.org/support/topic/validation-hook-1/#post-7478407)
 * Status: not resolved