New

Home / Widget / Extension / Custom PHP Validation for Elementor Pro Form

Custom PHP Validation for Elementor Pro Form

This extension will allow you to validate your form based on the conditions that you set.

You can use the variable $fields to access field values (eg $fields[“field_id”]). The validation succeeds only if the PHP code does not return or return false. If it returns [$field_id, $error_message], then the error message will be reported for that specific field.

Return an error if the date choice is before today

				
					if( $fields['date'] < date( "Y-m-d" ) ) {
    return ['date', 'You can\'t choose a date before today' ];
}
				
			

Accepts only time field between 7 PM and 10 PM

				
					if( $fields['time'] < 19 || $fields['time'] > 22 ) {
    return ['time', 'You must to choose a time between 7PM and 10PM' ];
}