nosir / cleave.js

Format input text content when you are typing...
http://nosir.github.io/cleave.js
Apache License 2.0
17.96k stars 1.62k forks source link

Is there a way to limit input chars? #680

Open saleh-esmaili opened 2 years ago

saleh-esmaili commented 2 years ago

Hi, I am trying to make an input that user can only enter these charecters: X, Y, Z, 0 to 9, +, -, *, /, %. What should I do?

stripedpurple commented 2 years ago

As far as I know cleave does not support your specific need. However you can use the HTML5 pattern attribute to validate the input.

<input name="name" pattern="^[XYZ0-9\+\-\*\/\%]+$"/>