Calling javascript on Next button being clicked

Hi all
I have a multi page form on my site. I need some custom validation. (Basically comparing 2 number fields which GF simply doesnt seem able to!!).
So how can I fire my custom js code when the Next button is clicked? I want it to fire when GF’s validation code fires.
Ive been looking at the javascript filters but cant see anything relevant.

Do you want to see if the two numbers are the same, or different, or some other comparison or calculation?

hi Chris

I have input_1 which is a number (currency) field. I also have input_2 which is also a number (currency) field. When the user clicks on the Next button, if input_2 > input_1 I need an error msg saying “Input 2 cannot be more than input 1”.

How can I do this?

The error msg also needs to display the same as how GF displays error messages (in red text under the relevant field). I can bodge it and have my own js fire an alert with the warning inside - but its a very hacky way of doing it.

I know GF offers php hooks and js hooks to handle things. Im not sure which to use. Maybe js if thats how GF handles its validation?

Thanks for your help Chris.

In that case, you will want to use the gform_field_validation filter (PHP):

That specific example shows comparing two fields. Your actual comparison will be different, but the approach is the same.