- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript Regex Validation
JavaScript Regular Expressions
JavaScript Regex Validation
Regular expressions are commonly used to check the shape of input.
Validation patterns must be anchored at both ends.
And they should always be backed up by checks on the server.
Example
Example
javascript
const digitsOnly = /^\d+$/;
console.log(digitsOnly.test("12345"));
console.log(digitsOnly.test("123a"));The output is true then false.
