You can validate all forms, one form, or one field in one form. To validate all forms, your quantity field would need to be the same ID in every form, which is not likely I don't think (if it is, then it's no problem to apply the same validation to the same field in every form.)
However, you can write one function to force whole numbers, then add it to every form with a add_filter line for each form and field you want to validate. It's not optimal, especially if you are creating new forms all the time.
The code you add to functions.php would look like this:
// form 17, field 4
add_filter("gform_field_validation_17_4", "force_whole_number", 10, 4);
// form 12, field 20
add_filter("gform_field_validation_12_20", "force_whole_number", 10, 4);
// form 4, field 11
add_filter("gform_field_validation_4_11", "force_whole_number", 10, 4);
// etc
// then add your function one time
function force_whole_number ($result, $value, $form, $field){
// your code here
}
Posted 11 years ago on Wednesday January 30, 2013 |
Permalink