javascript - Uncaught TypeError: Object function has no method 'split' -
no errors in console present, though function not seem adding dashes intended do. also, code creates formatting problems on site meaning wrong this.
code:
$('#inventory_accountnumber').blur(function(){ var accounts = $(this).val; var accountsnum = []; accountnum = accounts.split(","); for(var i=0;i<accountnum.length;i++) { var newstr = ''; if(accountnum[i].length == 24) { newstr += accountnum[i].substring(0,4) + '-'; newstr += accountnum[i].substring(4,7) + '-'; newstr += accountnum[i].substring(7,10) + '-'; newstr += accountnum[i].substring(10,14) + '-'; newstr += accountnum[i].substring(14,20) + '-'; newstr += accountnum[i].substring(20,24) + '-'; newstr += '0000-000'; accountnum[i] = newstr; } else if(accountnum[i].length == 32) { newstr += accountnum[i].substring(0,4) + '-' ; newstr += accountnum[i].substring(4,7) + '-'; newstr += accountnum[i].substring(7,10) + '-'; newstr += accountnum[i].substring(10,14) + '-'; newstr += accountnum[i].substring(14,20) + '-'; newstr += accountnum[i].substring(20,24) + '-'; newstr += '0000-000'; accountnum[i] = newstr; } } accountnum.join(','); $(this).val = accountnum; });
this culprit:
var accounts = $(this).val;
that should read:
var accounts = $(this).val();
what have there function reference, not value of function's return statement.
Comments
Post a Comment