0

I am trying to set the maxlength attribute for some password input fields. It is working fine for .credit-card-display but not for .securityCode. The same code works fine in all other browsers and IE10 & above.

$('.securityCode').attr('maxlength', '3');
$('.credit-card-display').attr('maxlength', '16');
$('.credit-card-display').attr('data-format',"dddddddddddddddd");                            $('#CREDIT_CARD_SECURITY_CODE').attr('maxlength', '3');
$('.securityCode').attr("placeholder", '000');

so please let me know how to solve this problem.

Ravi Chothe
  • 180
  • 5
  • 17
  • What difference does the console make? Are both of the referenced fields of `type="password"`? What are the differences between the working/non-working fields? – Rory McCrossan Oct 15 '15 at 10:22
  • for credit-card-display type is type="tel" – Ravi Chothe Oct 15 '15 at 10:23
  • $('.securityCode').attr('maxlength', '3'); if i run this script on console then working fine. – Ravi Chothe Oct 15 '15 at 10:24
  • IE 9 does not support placeholder : http://caniuse.com/#feat=input-placeholder but you can use shim or polyfill to achieve this check out this link : http://stackoverflow.com/questions/6366021/placeholder-in-ie9 – nywooz Oct 15 '15 at 10:25
  • but placeholder code also working fine...issue only for securityCode – Ravi Chothe Oct 15 '15 at 10:26

1 Answers1

0

I am solved this for below IE 9 version. only change version in if condtion.

if(navigator.appVersion.indexOf("MSIE .9")!=-1)
                                {
                                    $('#inputid').bind('keyup blur', function () {
                                        var $this = $(this);
                                        var len = $this.val().length;
                                        var maxlength = 3;
                                        if (maxlength && len > maxlength) {
                                            var inputvalue= $this.val().slice(0, maxlength);
                                            $this.val("");
                                            $this.val(inputvalue);
                                        }
                                    });
                                }
Ravi Chothe
  • 180
  • 5
  • 17