Form validation
-
If you click on “Know exactly what you want?” all the radio box lines have a red x when you send the form even if a value is selected adn I can’t see why
add_action('init','validate_radio'); function validate_radio() { remove_filter( 'wpcf7_validate_radio', 'wpcf7_checkbox_validation_filter', 10, 2 ); add_filter( 'wpcf7_validate_radio', 'radio_validation_filter', 10, 2 ); } function radio_validation_filter( $result, $tag ) { $name = $tag->name; $whatyouwant = isset( $_POST['whatyouwant'] ) ? trim( $_POST['whatyouwant'] ) : ''; $is_required = $tag->is_required() || $whatyouwant[0] !== ""; $value = ""; if (isset( $_POST[$name])) { $value = $_POST[$name]; } if ( $whatyouwant !== "" & $value == "" ) { $result->invalidate( $tag, wpcf7_get_message( 'invalid_required' ) ); } return $result; }
Is what I have added to the functions.php file
It doesn’t look as though $value is being set but I might be wrong
The page I need help with: [log in to see the link]
- The topic ‘Form validation’ is closed to new replies.