I have a textbox
where I want user to only input values like below example
I-MH-NGPR-UBR-0001
It means, a user can add only numbers
, alphabets
and -
. Other than this it should not allow user to enter anything.
How to do this in javascript
You can try this:
^[a-zA-Z0-9-]+$
const regex = /^[a-zA-Z0-9-]+$/m;
const str = `I-MH-NGPR-UBR-0001`;
if (str.match(regex))
console.log("matched");
else
console.log("not matched");
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments