Hi,
Can you please help me with my code? I would like to specifically know what code to use and where to put the code. I think I should put it in functions.css.
You can view the form at http://www.virtuecard.org. All I want, are for the fields to be required, but since I'm using default values someone can click the "request an invitation" button and it will submit the default values of "name" and "email". Instead, I'd like it to present an error message if the default values are presented.
-----
The form ID is 13 and the "name" field is field 4 and the "email" field is field 3.
Here's the code I added to my functions.php file that didn't work. I only attempted fixing field 4, but since that didn't work, I didn't code out for field 3 yet.
-----
<?php
add_filter('gform_validation_13', 'custom_validation');
function custom_validation($validation_result){
$form = $validation_result["form"];
//supposing we don't want input 1 to be a value of 86
if($_POST['input_4'] == name){
// set the form validation to false
$validation_result["is_valid"] = false;
//finding Field with ID of 1 and marking it as failed validation
foreach($form["fields"] as &$field){
//NOTE: replace 1 with the field you would like to validate
if($field["id"] == "4"){
$field["failed_validation"] = true;
$field["validation_message"] = "This field is invalid!";
break;
}
}
}
//Assign modified $form object back to the validation result
$validation_result["form"] = $form;
return $validation_result;
}
?>