Validation d'un formulaire écrit avec elementor pro
Bonsoir.
Apres avoir creer un champs texte. id = ticket_id.
Ce code ne fonctione pas.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| function elementor_form_validation( $record, $ajax_handler ) {
$fields = $record->get_field( [
'id' => 'ticket_id',
] );
if ( empty( $fields ) ) {
return;
}
$field = current( $fields );
if ( 1 !== preg_match( '/^\w{3}-\w{4}$/', $field['value'] ) ) {
$ajax_handler->add_error( $field['id'], esc_html__( 'Invalid Ticket ID, it must be in XXX-XXXX format.', 'textdomain' ) );
}
}
add_action( 'elementor_pro/forms/validation', 'elementor_form_validation', 10, 2 ); |
J'utulise elementor pro et des codes courts.
Ca répond toujour "valid" !!!
Merci pour votre aide votre amis philippe :D