KevinSheedy / jquery.alphanum

Alphanumeric Plugin for jQuery
Other
141 stars 65 forks source link

maxLength does not work for .numeric() and type="number" #66

Open madebyjero opened 8 years ago

madebyjero commented 8 years ago

I want to add a max length to a numeric value, but its not working. I want to validate CVV number of credit cards, which should be a number, and only have 3 or 4 characters.

This is the code I used:

$('.payment-details-cvv').numeric({
    maxLength: 4
  });

I added a jsfiddle to illustrate that the maxlength works on type="text", but not type="number" and not with .numeric() http://jsfiddle.net/j8rvhdy5/3/

unknown4unnamed commented 7 years ago

The same issue.

Abdelhady commented 7 years ago

maxLength is not allowed for type='number' by design, check out this answer, and I think there is nothing to do with the alphanum plugin here,

the workaround that worked for me, is using the type='tel' instead, which gives a slightly different (actually better :) ) keyboard, I think it will work with your requirement too.