Side navigation
#2694 closed bug (fixed)
Opened April 15, 2008 04:45PM UTC
Closed April 28, 2008 01:29PM UTC
[validate] creditcard validates true if alpa characters are used
| Reported by: | jforth | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 1.2.4 |
| Component: | plugin | Version: | 1.2.3 |
| Keywords: | validate creditcard | Cc: | |
| Blocked by: | Blocking: |
Description
creditcard rule validates true if alpa characters are used
example: asdf validates true.
Attachments (0)
Change History (3)
Changed April 15, 2008 07:46PM UTC by comment:1
Changed April 15, 2008 08:12PM UTC by comment:2
creditcard: function(value, element) {
if(/[^0-9-]+/.test(value)) return 0;
if ( this.optional(element) )
return "dependency-mismatch";
var nCheck = 0,
nDigit = 0,
bEven = false;
value = value.replace(/\\D/g, "");
for (n = value.length - 1; n >= 0; n--) {
var cDigit = value.charAt(n);
var nDigit = parseInt(cDigit, 10);
if (bEven) {
if ((nDigit *= 2) > 9)
nDigit -= 9;
}
nCheck += nDigit;
bEven = !bEven;
}
return (nCheck % 10) == 0;
}
Changed April 28, 2008 01:29PM UTC by comment:3
| resolution: | → fixed |
|---|---|
| status: | new → closed |
Fixed in [5340].
fix? maybe
creditcard: function(value, element) { if ( this.optional(element) ) return "dependency-mismatch"; if(value.match(/\\D/)) return 0; var nCheck = 0, nDigit = 0, bEven = false; value = value.replace(/\\D/g, ""); for (n = value.length - 1; n >= 0; n--) { var cDigit = value.charAt(n); var nDigit = parseInt(cDigit, 10); if (bEven) { if ((nDigit *= 2) > 9) nDigit -= 9; } nCheck += nDigit; bEven = !bEven; } return (nCheck % 10) == 0; }