score:1
Accepted answer
^\(\d{3}\)\s\d{3}-\d{4}$
This matches the given format exactly
https://regex101.com/r/HBvG3K/6
\( and \) - To escape () characters and match literally
\s - space character. If there can be more or no spaces then add * next to \s
\d{} - decimal numbers(0-9) followed by quantifier.
let validateSchema = yup.object().shape({
tel_no: yup
.string()
.matches(
/^\(\d{3}\)\s\d{3}\s-\s\d{4}/g,
"Telephone number is invalid"
)
});
score:0
score:0
I guess it would be better to use a real phone checking library like: https://github.com/catamphetamine/libphonenumber-js
Source: stackoverflow.com
Related Query
- Validating Telephone Number in RegEx in React
- React - Handling and validating a dynamic number of inputs
- Validating Mobile number using React - validator library
- Uncaught Invariant Violation: Too many re-renders. React limits the number of renders to prevent an infinite loop
- Get version number from package.json in React Redux (create-react-app)
- Only numbers. Input number in React
- "Error: Too many re-renders. React limits the number of renders to prevent an infinite loop."
- How to loop over a number in React inside JSX
- React native styling. width: percentage - number
- React native text component using number of lines
- React native send a message to specific whatsapp Number
- Initializing React number input control with blank value?
- Stop cursor jumping when formatting number in React
- Dynamically changing number of columns in React Native Flat List
- React js: Invariant Violation: processUpdates() when rendering a table with a different number of child rows
- React Native require(image) returns number
- Regex in React email validation
- Number input is string not integer in React
- How to allow only numbers in textbox and format as US mobile number format in react js? ex : (224) - 5623 -2365
- React - How to format phone number as user types
- React: Are there respectable limits to number of props on react components
- Sending number instead of string from Select in React component
- React Router 4 Regex paths - match doesn't find parameters
- Finding the number of rendered child components in react test using enzyme?
- React - Render a certain number of components dynamically
- React Native: mobile number validation accept numeric value only
- Validating URL Parameters in React Router v4
- How to limit the text filed length with input type number in React JS and prevent entry of E,e, -, + etc
- React material-ui textfield decimal step of 1.00 on 1.00 as a default number
- Can Proptypes Number in React take Float?
More Query from same tag
- Where do sockets fit into the Flux unidirectional data flow?
- Does React wait for render to update state?
- How to send data while routing from a div component to a new page in react?
- How can I redirect to error page when wrong url is entered?
- ES6 React istanbul No coverage information was collected, exit without writing coverage information
- Checkbox conditional rendering after action is performed - ReactJS
- React js TypeError: Cannot read property 'rfpid' of undefined
- ternary operators in return statement do not work in react useState Hook
- How can I check for null values within my data prior to passing onClick props?
- Is there a possibility to specify length of array that comes from props?
- Cannot read property 'user' of undefined, React Redux
- Error handling in react-query mutateAsync
- How can I convert popover MATERIAL-UI functional component to class based component?
- Can i still use expo after i detach my react native app?
- React State is not updated with socket.io
- TypeError: Cannot read property 'state' of undefined. Updated React
- How to control z index of CircleMarker of leaflet react?
- How to make 'this' refer to App, not modal
- export 'actionTypes' (imported as 'actionTypes') was not found in './pages.actionTypes'
- React not updating state from redux
- React-hook-form custom onChange handler in checkbox -> change is not registered
- Clickable routing without link tag in react js
- props is defined, but below undefined
- How do I draw a half circle outline SVG and fill it in with Javascript given a range of data?
- React Redux reading data from reducer in table
- React - Cannot read property 'question_desc' of undefined
- why does all other values update while i used useEffect() on just 'time'?
- Go Api returning Unauthorized
- How to use { useQuery } from react-query while iterating over an array of data
- React Antd Tree : get parent ID of selected Node