jquery.alphanum icon indicating copy to clipboard operation
jquery.alphanum copied to clipboard

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

Open madebyjero opened this issue 8 years ago • 2 comments

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/

madebyjero avatar Jun 28 '16 15:06 madebyjero

The same issue.

unknown4unnamed avatar Nov 30 '16 21:11 unknown4unnamed

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.

Abdelhady avatar Feb 13 '17 14:02 Abdelhady