Hi, is there a field I can use for an offer code. The code will be an alphanumeric string. Ideally I want to verify the code is valid before submitting form.
Thanks.
Hi, is there a field I can use for an offer code. The code will be an alphanumeric string. Ideally I want to verify the code is valid before submitting form.
Thanks.
There is no built in "offer code" functionality. It's possible to implement, but you would have to use a standard text input field and then use the gform_validation hook to write your own custom validation to validate this field. I'm not sure what your PHP and WordPress development skill level is... but here is an example of the gform_validation hook.
<?php
add_filter('gform_validation', 'custom_validation');
function custom_validation($validation_result){
// set the form validation to false
$validation_result["is_valid"] = false;
$form = $validation_result["form"];
// specify the first field to be invalid and provide custom validation message
$form["fields"][0]["failed_validation"] = true;
$form["fields"][0]["validation_message"] = "This field is invalid!";
// update the form in the validation result with the form object you modified
$validation_result["form"] = $form;
return $validation_result;
}
?>
The gform_validation hook allows you to specific custom validation for a field. So you could use it to validate a string against a database table containing values, or virtually anything you want to do from a validation standpoint as long as you know how to write the code.