<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Jonathan's Blog - Latest Comments</title><link xmlns="http://www.w3.org/2005/Atom" rel="http://api.friendfeed.com/2008/03#sup" href="http://disqus.com/sup/all.sup#forumcomments-5d6c9c39" type="application/json"/><link>http://garetjax-blog.disqus.com/</link><description>Personal weblog of Jonathan Stoppani</description><atom:link href="http://garetjax-blog.disqus.com/comments.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Thu, 03 May 2012 13:27:47 -0000</lastBuildDate><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-517850413</link><description>&lt;p&gt;Johnathan you are awesome. I modified your stuff to be automatic using ajax. I will share.&lt;/p&gt;

&lt;p&gt;&amp;lt;script type="text/javascript"&amp;gt;$(document).ready(function() {    // Create a new reader instance    var reader = new CardReader();&lt;br&gt;    // Feed it an object to observe (this could also be a textbox)    reader.observe(window);&lt;br&gt;    // Errback in case of a reading error    reader.cardError(function () {  $("#resercardinfo").text("ERROR: Try swiping  the card again please!");     //alert("Try Swiping again please");    });&lt;br&gt;    // Callback in case of a successful reading operation    reader.cardRead(function (value) {        $('form input#resercardnumber').val(value);        //$('from').submit();    // Setup AJAX stuff to parse the info read  $.getJSON("support/ajax/parsecard.php?id="+value,null,  function(data, textStatus, xhr)  {   var ccdata = data.cctype + ' in the name of ' + data.ccname;&lt;br&gt;   $("#resercardinfo").text(ccdata);   $("#resercardread").val(data.ccread);   $("#resercardname").val(data.ccname);   $("#resercardtype").val(data.cctype);   $("#reserccnum").val(data.ccnum);   $("#reserccexp").val(data.ccexp);  });    });});&amp;lt;/script&amp;gt;&lt;br&gt;Here's the PHP&lt;br&gt; ".$cardData; $cardRet['ccread'] = $cardData; //error_log($cardRet['ccread'], 0);  $cardRet['ccname'] = $ccname; //error_log($cardRet['ccname'], 0);  $cardRet['cctype'] = $cardType; //error_log($cardRet['cctype'], 0);  $cardRet['ccnum'] = $cardNum; //error_log($cardRet['ccnum'], 0);&lt;br&gt; $cardRet['ccexp'] = $ccexp; //error_log($cardRet['ccexp'], 0);}else{  $ins = "Card Read Failed"; $cardRet['ccinfo'] = $ins; //error_log($ins, 0);}&lt;/p&gt;

&lt;p&gt;echo json_encode($cardRet);?&amp;gt;&lt;br&gt;Hope that helps someone!&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">ShonGale</dc:creator><pubDate>Thu, 03 May 2012 13:27:47 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-517414654</link><description>&lt;p&gt;Sure, it's everything that is supported by jQuery: &lt;a href="http://api.jquery.com/jQuery/#jQuery1" rel="nofollow"&gt;http://api.jquery.com/jQuery/#...&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jonathan Stoppani</dc:creator><pubDate>Thu, 03 May 2012 03:13:16 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-516907502</link><description>&lt;p&gt;Hello again. Can you list the values that can go into the .observe() function.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">ShonGale</dc:creator><pubDate>Wed, 02 May 2012 14:24:54 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-516905676</link><description>&lt;p&gt;Anybody still out there? It appears to work flawlessly with a MagTek 21040108 HID USB scanner .. $45.00 new. Has to be HID and where ever you want to capture the info has to have the focus. Not a field but using his code the current window. Works awesome.&lt;br&gt;Here's the code:&lt;br&gt;&amp;lt;meta content="text/html; charset=UTF-8" http-equiv="Content-Type"&amp;gt;&amp;lt;title&amp;gt;jQuery Card reader&amp;lt;/title&amp;gt;&amp;lt;script src="/rez/support/jquery/jquery-1.7.1.min.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;script charset="utf-8" src="/rez/support/jquery/jquery.cardreader.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;script type="text/javascript"&amp;gt;jQuery(function () {	// Create a new reader instance	var reader = new CardReader();	// Feed it an object to observe (this could also be a textbox)	reader.observe(window);	// Errback in case of a reading error	reader.cardError(function () {		alert("A read error occurred");	});	// Callback in case of a successful reading operation	reader.cardRead(function (value) {		$('form input#card_number').val(value);		//$('form').submit();	});});&amp;lt;/script&amp;gt;&lt;br&gt;&lt;/p&gt;&lt;p&gt;Swipe your card and press the submit button&lt;/p&gt;&amp;lt;form action="testcard.php" method="post"&amp;gt;	&amp;lt;input id="card_number" name="card_content" type="hidden"&amp;gt;    &amp;lt;input id="cardsub" name="cardsubmit" type="submit" value="Submit"&amp;gt;&lt;br&gt;&amp;lt;hr&amp;gt;&lt;br&gt;';	echo sprintf("firstChar = %s, start = %d, caretStart = %d, cardEnd = %d&lt;br&gt;",$firstChar, $start, $caretStart, $cardEnd);	echo '&lt;br&gt;Card Number: ' . $cardNum . '&lt;br&gt;';	echo sprintf("caretPos = %d, nameEnd = %d, cardHolder = %s&lt;br&gt;",$caretPos, $nameEnd, $cardHolder);	echo 'Card Type: ' . $cardType;	if ($cardType == "MasterCard")		echo '&lt;br&gt;Customer Name: ' . $firstName . ' ' . $midInit . ' ' . $lastName . '&lt;br&gt;';	else			echo '&lt;br&gt;Customer Name: ' . $firstName . ', ' . $lastName . '&lt;br&gt;';	echo sprintf("expDate = %s, expYear = %s, expMonth = %s&lt;br&gt;", $expDate, $expYear, $expMonth);}?&amp;gt;&lt;br&gt;You will notice that I commented out the submit command in his code because it wouldn't verify as to the submit button. Plus I didn't want to submit immediately. Have fun this code base works great.&amp;lt;/form&amp;gt;&lt;p&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">ShonGale</dc:creator><pubDate>Wed, 02 May 2012 14:22:52 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-445556236</link><description>&lt;p&gt;Hello, i had this code implemented on some url... Now i am trying to swipe the card after opening this url in browser but nothing happens in browser... Card swipe only provides output to a notepad file (mine card reader is MSR213U).. Please guide through.....&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Sunny85indore</dc:creator><pubDate>Wed, 22 Feb 2012 02:04:56 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-439344467</link><description>&lt;p&gt;I've done everything mentioned in this blog, yet my card reader doesn't send anything.  Is there a way to dump the actual method being called when the card is being swiped? &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">BlackberryAddict</dc:creator><pubDate>Tue, 14 Feb 2012 18:25:03 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-413371273</link><description>&lt;p&gt;@nilesh u talking about my comment or overall page?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jazzy</dc:creator><pubDate>Tue, 17 Jan 2012 09:10:27 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-413350236</link><description>&lt;p&gt;Works flawless.....&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Nilesh</dc:creator><pubDate>Tue, 17 Jan 2012 08:29:43 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-407180592</link><description>&lt;p&gt;Any cheap card reader you guys can recommend for this kind of project? I found one on ebay, not sure will it work with this :&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.ebay.com/itm/Honeywell-IDRA-335133B-DL-DELL-ONLY-MSR-USB-HID-3TRK-magnetic-strip-card-reader-/230687770687?pt=LH_DefaultDomain_0&amp;amp;hash=item35b610083f#shId" rel="nofollow"&gt;http://www.ebay.com/itm/Honeyw...&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jazzy</dc:creator><pubDate>Tue, 10 Jan 2012 11:08:16 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-376000758</link><description>&lt;p&gt;I didnt need to do all that fancyness with the timing of when keys were pressed. I just had to record the card reader and then submit the form once done. I stuffed the cc data into a hidden field.. heres my code (I'm using &lt;a href="http://asp.net" rel="nofollow"&gt;asp.net&lt;/a&gt; and also jquery):&lt;/p&gt;

&lt;p&gt;    &amp;lt;script type="text/javascript"&amp;gt;        //this attaches the keyup event to the html element to capture all keypress' and puts them in the hidden field        $(function () {            var btnSubmit = document.getElementById('&amp;lt;%= btnSubmit.ClientID %&amp;gt;');            btnSubmit.focus();            $('html').keypress(function (e) {                var keyPressed = e.which;                var hiddenField = document.getElementById('&amp;lt;%= creditCardDetailText.ClientID %&amp;gt;');                if (keyPressed != 13) {                    hiddenField.value += String.fromCharCode(keyPressed);                }             });        });    &amp;lt;/script&amp;gt;&lt;/p&gt;

&lt;p&gt;the (keypressed != 13) makes sure I dont capture the enter key after its done reading.&lt;/p&gt;

&lt;p&gt;I got the idea to do it like this after looking through your code.. Thanks!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Evan Larsen</dc:creator><pubDate>Wed, 30 Nov 2011 11:34:02 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-374340291</link><description>&lt;p&gt;Rick, let us know if you find a IE work around. &lt;/p&gt;

&lt;p&gt;On a side note if your using an RFID reader and all it posts is the number and then enter, so no track or end senitel is the start and end bits still required?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">John</dc:creator><pubDate>Mon, 28 Nov 2011 13:38:07 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-361314117</link><description>&lt;p&gt;Update: I still am having issues, but at least I am moving a little closer to getting this to work in all browsers.  For anyone else having issues, If you change the jQuery read.observe object to document, instead of window, IE will at least read in all the characters.  I am having an issue however with the call back.  After the last information is read, it is not firing the callback function reader.cardRead in IE 8, and IE9 in compatibility mode.  Any infomation you can provide would be greatly appreciated.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Rick</dc:creator><pubDate>Fri, 11 Nov 2011 15:36:11 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-353424616</link><description>&lt;p&gt;Correction...  The code does work in IE9 as long as compatibility mode is off.  Does not work at all in IE8.  Any help is appreciated.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Rick</dc:creator><pubDate>Wed, 02 Nov 2011 02:41:34 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-353424211</link><description>&lt;p&gt;Anyone having any issues with IE?  I have this working great on all browsers (Chrome, Firefox, Safari, and Opera) , but sadly, it does not work in IE8 or IE9.  I also need this to work in compatibility mode.  When switched into compatibility mode, the javascript errors out at not understanding what CardReader even is.  It does not see it as an object class.  Any help would be appreciated.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Rick</dc:creator><pubDate>Wed, 02 Nov 2011 02:39:28 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-280297105</link><description>&lt;p&gt;I am trying to get this to work with jquery 1.6.2.. My card reader works fine on your timing test page as well as in notepad or in anything else for that matter.. I got your script set up and a form field to set the value to.. i know your script is set up as when i swipe on any normal page it tries to find the data read from the card using the ctrl+f search box.. but on my page i set up nothing happens when i swipe.. any ideas? incompatible with 1.6.2?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Danieliser</dc:creator><pubDate>Mon, 08 Aug 2011 03:50:59 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-212259920</link><description>&lt;p&gt;If your Card Reader is seen as an HID, then yes. Note that it may need some adaptation, but the working principle will stay the same.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jonathan Stoppani</dc:creator><pubDate>Thu, 26 May 2011 12:26:06 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-212257548</link><description>&lt;p&gt;Does this jquery and cardreader work with any magnetic swipe card reader and thereby eliminates the need for the use of the dll that comes with it?&lt;/p&gt;

&lt;p&gt;If this is the case than it will save me quite a bit on the web app I am working on. &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">myfundi</dc:creator><pubDate>Thu, 26 May 2011 12:21:17 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-194106820</link><description>&lt;p&gt;Joe, actually no, I don't see any problems other than the "immaturity" of the code. It is a good base to build upon but still has some bugs and limitations as exposed in the comments above. Other than that it should work greatly... ;-)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jonathan Stoppani</dc:creator><pubDate>Fri, 29 Apr 2011 10:05:15 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-194105949</link><description>&lt;p&gt;Thanks for this article.  I am doing some feasibility research on building a Point of Sale system through a web browser.   Do you see any reason why I couldn't use this jquery example to capture credit cards info swiped through an MSR?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Joe</dc:creator><pubDate>Fri, 29 Apr 2011 10:03:00 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-167654675</link><description>&lt;p&gt;Kevin,&lt;/p&gt;

&lt;p&gt;Your card reader must support "HID" ("Human Interface Device"), which is a standard whereas a card reader (or barcode scanner, etc) behaves just like a standard computer keyboard (i.e., in a sense it "emulates" a keyboard presses).&lt;/p&gt;

&lt;p&gt;Hope that helps.&lt;/p&gt;

&lt;p&gt;- jose&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jose</dc:creator><pubDate>Fri, 18 Mar 2011 11:22:29 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-120838652</link><description>&lt;p&gt;Where did you get the value for the error track ID?  I can not find any documentation that shows an error track ID of é (Hex E9) .  The PDF referenced on this page does not show that.   It states that an error will be: 'TrackID' + 'E' + 'ES' + 'ENTER' but does not state that the TrackID is anything different from the three main TrackIDs.  &lt;/p&gt;

&lt;p&gt;I'm still trying to figure out my problem, but I can say that if I capture a value in the cardError callback, it is the track data.  So, the data is getting read, but it seems that an isError is getting set incorrectly.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Scott</dc:creator><pubDate>Wed, 29 Dec 2010 15:42:38 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-111869781</link><description>&lt;p&gt;has anyone got this to work? my card reader when i swipe a card nothing happens on the screen.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Kevin</dc:creator><pubDate>Tue, 14 Dec 2010 20:02:44 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-65448717</link><description>&lt;p&gt;Here you go: &lt;a href="http://gist.github.com/502257" rel="nofollow"&gt;http://gist.github.com/502257&lt;/a&gt;&lt;br&gt;As you can see the body contains a form with an invisible field, the script will show you an alert box if a read error occurs or submit the page with the results (the card content can then be read from the URL). Also turn on the console output in your web browser to receive debugging messages from the class itself. ;-)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jonathan Stoppani</dc:creator><pubDate>Sat, 31 Jul 2010 10:56:03 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-65445699</link><description>&lt;p&gt;Thanks for the reply Jonathan.&lt;br&gt;"The HTML above is not enough, you should already have a complete working page and the snippet is the scripting part to add to capture the reader input."&lt;br&gt;Could you elaborate? Would it be enough to make a &amp;lt;div&amp;gt;&amp;lt;/div&amp;gt; and call the function within? Some minimalistic test page code would be appreciated (I'm new to jQuery....)&lt;br&gt;Btw, the key-delay test page was just amazing.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ursula</dc:creator><pubDate>Sat, 31 Jul 2010 10:35:55 -0000</pubDate></item><item><title>Re: Using a magnetic card reader with jQuery</title><link>http://garetjax.info/blog/articles/2010/01/magnetic-card-jquery/#comment-65433002</link><description>&lt;p&gt;Thank you for the reply. I achieved it by checking whether any input element is in focus and inserted the start sentinel value to that element through the timeout event.&lt;/p&gt;

&lt;p&gt;// extend the jquery to have a custom selector.&lt;br&gt;// this is used to check if an element has its focus.&lt;br&gt;// usage: $("input:focus").doStuff();&lt;/p&gt;

&lt;p&gt;jQuery.extend(jQuery.expr[':'], {&lt;br&gt;    focus: "a == document.activeElement"&lt;br&gt;});&lt;/p&gt;

&lt;p&gt;And modified the first timeout event to be like this:&lt;/p&gt;

&lt;p&gt;this.timer = setTimeout(function () {&lt;br&gt;    ob.started = false;&lt;br&gt;    ob.finished = false;&lt;br&gt;    ob.isError = false;&lt;br&gt;    ob.input = "";&lt;br&gt;    $("input:focus").val($("input:focus").val() + String.fromCharCode(ob.track_start));&lt;br&gt;}, this.timeout);&lt;/p&gt;

&lt;p&gt;This solved the problem if someone tried to enter % in any of the input elements in the page.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Nirmal</dc:creator><pubDate>Sat, 31 Jul 2010 07:40:06 -0000</pubDate></item></channel></rss>
