About a month ago I started working with the CodeIgniter framework. It’s the first framework I have worked with and frankly, I love it!
So I was looking to add a second parameter to a form_validation callback. Here’s what I found:
$this->form_validation('user_name', 'name', "callback_test_name[$param2]");
and the callback:
test_name($name, $param2){
..// some logic to return
}
The form_validation class uses the form value as the first parameter, and you can pass the second parameter in the arguments as you would with any other rule references. (First snippet)
At first I was calling 2 validations. First the standard type of validation, then another validation on the same input. * BAD IDEA *
There were some issues with order of operations. I found it best to chain the whole lot together. Like so:
$this->form_validation('user_name', 'name', "required|min_length[10]|callback_test_name[$param2]");
I hope that helps anybody with the same question.
I was on the hunt not only to find the different variations each courier had for their tracking numbers but also a regex to match. Most of the google fu I found was outdated. Fedex “recently” (months? years? days?) changed from a 12 digit to 15 digit system. And NO, tracking numbers are not totally random. There is usually a space separation on the printed labels you see. Each of the spaced out subsets have a meaning to the courier as well as a checksum. Checksum being, a pre selected sequence of particular number positions added together then divided by a pre selected number. That you can search up yourself if you like. I didn’t find all too much on that matter either.
I am not very good with regex so if there are any suggestions by l33t coderz, they are more than welcome. On with the codes:
/****
[ UPS ]
9 digits, or 1Z+whatever digits
The quick brown fox 1Z9999W99999999999 jumps over the lazy dog.
*/
$ups = '/(\b\d{9}\b)|(\b1Z\d+\b)/';
/****
[ Fedex ]
12 digits, 15 digits, or '96'+ 20 digits
The quick brown fox 999999999999 jumps over the lazy dog.
*/
$fedex = '/(\b96\d{20}\b)|(\b\d{15}\b)|(\b\d{12}\b)/';
/***
[ USPS ]
30 digits, '91'+20 digits, 20 digits (untested)
< TOTALLY UNTESTED BY ME AT THIS TIME >
*/
$usps = '/(\b\d{30}\b)|(\b91\d+\b)|(\b\d{20}\b)/';
I did get the common characters per courier from Packagetrackr. I don’t know how much of it is accurate, but from what I could tell from my experience with FedEx and UPS it seemed to be in line. I was unable to find an all inclusive source.
I had been using an autocomplete plugin by bassistance. 2 months later jQuery UI added autocomplete to their list of widgets. Like many plugins out there I was unable to find an autocomplete that was easy to use for my purposes. The closest I recently came to was the sexy combo plugin. I cant remember why but it was just a tad short of what I wanted to do, and I’m still quite a javascript novice.
I came up with a way to use the jQuery UI autocomplete widget as a <select> that you could also type in something if the choices in the dropdown didn’t fit your needs.

This example uses a local data source, but you can come up with creative ways to use remote JSON sources if you like.
<script type="text/javascript">
$(document).ready(function() {
// dropdown/ auto suggest
$(".ui_dropdown").autocomplete({
minLength: 0,
delay: 0
});
$(".ui_dropdown").click(function(){
var input = $(this);
var inputID = input.attr('id');
// close if already visible
if (input.autocomplete("widget").is(":visible")) {
input.autocomplete("close");
return false;
}
// set source(s)
var myData = '';
if(inputID == 'input1'){
myData = ["foo","bar","hello","world"];
} else {
myData = ["1","2","3","4"];
}
// load source
input.autocomplete({
source: myData
});
// fire search event
input.autocomplete("search", "");
input.focus();
return false;
});
});
</script>
In this script I am using the input id’s to define the data source.
I’m rather new to both javascript and jQuery. I ran into an issue while cloning table rows that had inputs, and jQuery UI datepicker.
The cloned datepicker input would insert the picked date into the original inputs rather than the cloned row.

The inputs in my table rows had no ID’s. So what I found was either jQuery or UI was dynamically creating it’s own DOM id’s for the inputs in the table rows that had the datepicker call. Datepicker also was dynamically inserting a class “hasDatepicker” into the inputs that had the datepicker call.
I resolved this by:
1. Looping through the cloned rows inputs looking for any inputs with the class “hasDatepicker”.
2. Removing the hasDatepicker class from any inputs with that class.
3. Getting that inputs current id, incrementing it by 1, and reassigning it.
4. Re-initializing the datepicker call.
<script type="text/javascript">
$(document).ready(function(){
// -- Clone table rows
$(".cloneTableRows").live('click', function(){
// do the cloning...
// new rows datepicker need to be re-initialized
$(newRow).find("input").each(function(){
// if the current input has the hasDatpicker class
if($(this).hasClass("hasDatepicker")){
var this_id = $(this).attr("id"); // current inputs id
var new_id = this_id +1; // a new id
$(this).attr("id", new_id); // change to new id
$(this).removeClass('hasDatepicker'); // remove hasDatepicker class
$(this).datepicker(); // re-init datepicker
}
});
});
});
</script>
Whats really neat about this particular js, is that you can call it from any table that has an id.
The only thing I have yet to figure out is how to reset the cloned datepicker to use the default class called date format.
So in addition to reformatting friends and relatives computers, about every 2 years I clean out my own. Each time I have, I’ve lost my Notepad++ FTP synchronize settings.
In Vista they can be found in:
C:\Users\AppData\Roaming\Notepad++\plugins\config\FTP_synchronize.ini

Copy them to backup and replace. In case an update gets hosed, or you are re-installing.