Title: Custom Validation
Last modified: October 19, 2022

---

# Custom Validation

 *  Resolved [sagescorp](https://wordpress.org/support/users/sagescorp/)
 * (@sagescorp)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/custom-validation-24/)
 * Hello sir,
    I want to add custom validation a textarea. Tried different options
   but no success. Can you help me to solve this issue.
 *     ```
       add_action( 'user_registration_validate_textarea_1666081401','ur_validate_textarea_1666081401',10,4);
       function ur_validate_textarea_1666081401($single_form_field, $data, $filter_hook, $form_id) {    
       	global $wpdb;
           $field_label = isset( $data->label ) ? $data->label : '';
           $value = isset( $data->value ) ? $data->value : '';
       	if( 'textarea_1666081401' === $single_form_field->general_setting->field_name ) {
       		if ( 10 < strlen( $value ) ) {
       		add_filter($filter_hook, function ( $msg ) use ( $field_label ) {
       			return __( $field_label . ' cannot exceed 10 characters.', 'user-registration' );
       			});
       		}
       	}
       }
       ```
   
 * Thank you

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Thread Starter [sagescorp](https://wordpress.org/support/users/sagescorp/)
 * (@sagescorp)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/custom-validation-24/#post-16116911)
 * Any update on this sir?
 * Thank you
 *  Plugin Support [Amrit Kumar Shrestha](https://wordpress.org/support/users/shresthauzwal/)
 * (@shresthauzwal)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/custom-validation-24/#post-16116957)
 * Hi [@sagescorp](https://wordpress.org/support/users/sagescorp/),
 * It seems you are trying to limit the character on the Textarea field. We suggest
   you use the input field and the prebuilt limit character feature if you want 
   to limit a maximum number of characters. For more clarification, please check
   this screenshot [https://prnt.sc/DMxzlAvHTTom](https://prnt.sc/DMxzlAvHTTom)
 * Regards!
 *  Thread Starter [sagescorp](https://wordpress.org/support/users/sagescorp/)
 * (@sagescorp)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/custom-validation-24/#post-16116969)
 * Ok sir,
    Thanks for your help
 *  Plugin Support [Amrit Kumar Shrestha](https://wordpress.org/support/users/shresthauzwal/)
 * (@shresthauzwal)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/custom-validation-24/#post-16117114)
 * Hi [@sagescorp](https://wordpress.org/support/users/sagescorp/),
 * Glad to know that, if you have a moment to spare then we would really appreciate
   your review of our plugin. Please click on this link [https://wordpress.org/support/plugin/user-registration/reviews/#new-post](https://wordpress.org/support/plugin/user-registration/reviews/#new-post)
   and share your thoughts about our team and our plugin. We would love to hear 
   from you.
 * Regards!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Custom Validation’ is closed to new replies.

 * ![](https://ps.w.org/user-registration/assets/icon-256x256.gif?rev=3284028)
 * [User Registration & Membership - Free & Paid Memberships, Subscriptions, Content Restriction, User Profile, Custom User Registration & Login Builder](https://wordpress.org/plugins/user-registration/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/user-registration/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/user-registration/)
 * [Active Topics](https://wordpress.org/support/plugin/user-registration/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/user-registration/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/user-registration/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Amrit Kumar Shrestha](https://wordpress.org/support/users/shresthauzwal/)
 * Last activity: [3 years, 7 months ago](https://wordpress.org/support/topic/custom-validation-24/#post-16117114)
 * Status: resolved