Hi all. After being away from coding and trying this for a while I have been asked to assist someone with something and I am not winning.....or understanding how to check the form validation coming though. The 'friend/client' needs to check that the form field filled in begins with 'DT' (either upper case or lower case) can have a space(or not) then a series of 7 numbers. For example 'DT 1234567' or 'dt1234567'
I am really not understanding how to do this. I have started with some sample code
/**
* Validate UM DT Number field for registration dt_number2
* @param string $key
* @param attay $array
* @param array $args
*/
function um_custom_validate_dt_number2( $key, $array, $args ) {
if ( isset( $args[$key] ) && !preg_match('/^[6-9]\d{9}$/', $args[$key]) ) {
UM()->form()->add_error( $key, __( 'Please enter a valid DT Number.', 'ultimate-member' ) );
}
}
add_action( 'um_custom_field_validation_dt_number2', 'um_custom_validate_dt_number2', 30, 3 );
but for the life of me, everything I have tried on sites like http://www.santic.org/preg_match/ just dont work, I get errors all the time. The best I can do is check that there is a DT in the string!
/(TD)\w*/i
checked against my string TD 1234567, 1236547 TD, 123DT4567 gives me 2 results, but as soon as I try check for numbers etc
/(TD)+[0-9]\d{7}\w*/i
I am failing. Please someone guide me!