-
-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
regex pattern not working #236
Comments
@santhoshkarthi002: The validation object is being passed to react-hook-form, but it is not triggering the error. This behavior persists even when using native HTML input. Try using validate instead of pattern in validation prop. validation={{
validate: (value) => {
if (!/^(0|[1-9]\d*)$/.test(value)) {
return 'Duration should have minimum of 1';
}
},
}} |
it,s working, Thank you. |
Just for anyone finding this, with v7 the solution above is no longer valid. Check the v7 beta announcement (#252 ) for details. Essentially it must now be <TextFieldElement
...
rules={{
validate: (value) => {
if (!/^$|^\d+[.,]?\d{0,2}$/g.test(value)) {
return 'Please enter a valid number..';
}
}
}}
/> |
Duplicates
Latest version
Current behavior 😯
how can i put regex pattern to textfield element for validation
Expected behavior 🤔
No response
Steps to reproduce 🕹
Steps:
The text was updated successfully, but these errors were encountered: