I've searched everywhere but can't find a regex for this.
I'm working with react-hook-form. Pattern key under register will evaluate a value with a regex. If it returns false, there is no error. If I add a number in the field, I get an error, which is the expected result. I'm using this regex:
/^[^0-9]*$/
I have set that if numbers are present, the field should return an error. I need for the field to return an error when spaces exist in the field.
I've tried /^[^0-9^\S]*$/ without avail.
Any help is greatly appreciated.
EDIT: This question has been tagged as redundant but the problem with the tagged solution is that spaces are allowed after characters have been typed in. I need a regex that can detect spaces or numbers or special characters anywhere in the string. I need to only allow characters and hyphens.