Hi @jimfr
Yes that’s possible with a little custom coding. Please copy and paste the following snippet into your theme’s functions.php file – at the bottom of it.
function pno_validate_zipcode( $fields ) {
if ( isset( $fields['listing_zipcode'] ) ) {
$max = 5;
$message = 'Your error message goes here';
$validator = new PNO\Validator\LessThanEqual( $max, $message );
$fields['listing_zipcode']['validators'] = $validator;
}
return $fields;
}
add_filter( 'pno_listing_submission_form_fields', 'pno_validate_zipcode' );
add_filter( 'pno_listing_editing_form_fields', 'pno_validate_zipcode' );
You should also customize the error message within the $message variable.
Hope this helps 🙂
Thread Starter
jimfr
(@jimfr)
Thanks @alessandrotesoro very good !
I copied the exact same code, but it always fails ?
Never mind, this is the validator which worked
PNO\Validator\Length
the less then equal one compares a numeric e.g the value must be less than 5