When I execute the following JavaScript function I receive the following error:
'2' is null or not an object.
The input from txtRawCardData
element is a string containing ^
character which I split into an string array.
Update
I receive this error only when I run my jQuery code in Internet Explorer 7. I do not receive this error when I run it FireFox 3.5.6.
Update 2:
This error is also preventing any JavaScript functions I wrote for any ASP.NET CustomValidator
controls from firing.
Sample Input:
%B1234123412341234^JOHNSON/JOCKO^1234123412345700000000123000000?;1234123412341234=123443211234567?
function ProcessCCInfo() {
var rawData = $('#txtRawCardData').val();
rawData = rawData.replace('\n\r', '');
var CCArray = rawData.split('^');
//format the card holder name
var NameArray = CCArray[1].split('/');
var CCName = NameArray[1] + ' ' + NameArray[0];
var CCNumber = CCArray[0].replace('%B', '');
var CCExpiration = CCArray[2].substring(0,4) //this is the line generating the error!
var FormattedDate = CCExpiration.substring(2,4) + '/' + CCExpiration.substring(0,2);
$('#spanCardHolderName').attr('innerHTML', CCName);
$('#spanCCNumber').attr('innerHTML', CCNumber);
$('#spanCCExpirationDate').attr('innerHTML', FormattedDate);
setTimeout("$('#txtCustomerId').focus()", 1000);
}
Anyone know why it threw this error?