Archive

Archive for September, 2009

Luhn Algorithm & General Credit Card Validity

September 11th, 2009
A interesting little tidbit i heard about today. All the major credit card companies (in the US at least) use something called the ‘Luhn algorithm’ to do a general validation on a credit card number. Checking out the Wikipedia Article about the algorithm, a whole mess of identification uses this “mod 10″ algorithm.


Code
: E-Commerce Tip: Programmatically Validate Credit Card Numbers

Just a quick way to determine if you should even move on to more detailed validation (is it a Visa?) before trying to charge the charge itself.
There is your fun fact for the month.

Uncategorized

.NET Partial Postback in Update Panel Breaks jQuery Autocomplete

September 9th, 2009

If you’ve never had the pleasure of working jQuery, than you need to stop what you are doing and go check it out.  Its a cool little JavaScript library that makes throwing some AJAX into your site a snap.

I’ve used jQuery Autocomplete before, and it generally looks something like this:

<script language=”javascript” >
$().ready(function() {
$(”.CLASSNAME”).autocomplete(JobTitles);
$(”#clear”).click(function() {
$(”:input”).unautocomplete();
});
});
</script>

Basically it takes my text box that i have set as class=”CLASSNAME” and in this example a javascript array called JOBTITLES and basically ’suggests’ values that match what they’ve type in so far. Very very handy tool.

I implemented it in a recent project where i was searching a list of names so people could easily search and select the name to add.  I had this all wrapped up in an update panel that actually resides in a web user control and had multiple instances of it due to it being printed out in a repeated. Everything worked great….

Then i noticed after i signed up one of the names, my auto-complete broke, WTF? Turns out the update panel does a partial postback that breaks the jQuery. You can find out more information about that here and here.

So in the end i updated my code to look like this:

<script type=”text/javascript” language=”javascript” >
function pageLoad() {
$(”.CLASSNAME”).autocomplete(JOBTITLES);

$(”#clear”).click(function() {
$(”:input”).unautocomplete();
});
}
</script>

… and that did the trick!

Also found this article: $(document).ready() and pageLoad() are not the same!

General .NET, jQuery

Learning Fail

September 4th, 2009

Well i never blogged about the book, i never even finished the book.  I get bored with lectures even when it comes from a crazy book! Instead I’ve been harassing a CSUN student i know to give me his class projects and futz with them. I find it kinda fun and i can’t wait to get to CSUN.

I’m lazy, deal with it

Looking for some small/short-term programming assignments to learn from? Well i found a few websites for you! Thanks to stackoverflow.com.

While i don’t seem to be able to use the Safari Book Online resource to read a book straight through, i find it really helpful for reference. Sometimes when i’m at work and i need some detailed knowledge about a subject i can load it up,  select the book(s) i want that seem to meet my requirement, and then have at it. I find it easier to get ‘real’ knowledge quickly when i can’t trust some random search on Google.

Uncategorized