Validate ALL email fields server side
-
Hello,
I just figured out how to do a server side validation of specific fields with Ninja Forms. I want to validate entered emails. However, my customer has a lot of forms on his page and he will likely add more. How can I validate EVERY email fields that will ever be submitted?
My code for validation of a specific fields looks like this:
function nf_submit_data( $form_data ) { $field_id = '715'; // validation part $registration_email = $form_data['fields'][ $field_id ]['value']; if ( ! ( strstr( $registration_email, '@' ) ) ) { // error message $form_data['errors']['fields'][ $field_id ] = 'This Email not allowed'; } return $form_data; } add_filter( 'ninja_forms_submit_data', 'nf_submit_data' );That will only validate one specific field (with the ID 715). My customer will add more and more email fields, that will have to get server side validation (due to security reasons), without me being around to add all these fields in the code. So what can I do?
The topic ‘Validate ALL email fields server side’ is closed to new replies.