Sunday, October 10, 2010

Jquery Validation - DATE mm/dd/yyyy format

Experimenting with JQuery, I was asked to add certain validations for the form, DATE in mm/dd/yyyy format.

Well not very difficult, below is the code..


<-- Include JQuery -->

<script charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>

<-- Include the Validation Plugin, NOTE - I have included from MS website instead of dev.jquery.com, it was down while working and throwing error in VALIDATOR method -->

<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.js"></script>

<-- Now add a Method to validate date in mm/dd/yyyy format with the regular expression -->

<script>
$(document).ready(function(){
    $.validator.addMethod("DateFormat", function(value,element) {
        return value.match(/^(0[1-9]|1[012])[- //.](0[1-9]|[12][0-9]|3[01])[- //.](19|20)\d\d$/);
            },
                "Please enter a date in the format mm/dd/yyyy"
            );
 $("#form5").validate({
        rules: {
            arrival: {
                required: true,
                DateFormat: true
            },
            departure : {
                required: true,
                DateFormat: true
            }
        }
    });
  });
</script>

That's all what is required ..

Note you can include the validation plugin from http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js as well, but as I wrote above it was down while writing this post.

Thursday, September 2, 2010

PHP - Saving included php file in a variable

I am a ColdFusion Developer, got some work to do on PHP, below is a very basic thing, but being CF programmer you are used to using <cfsavecontent> tag to save contents of entire file, how can this be done using php, well sounds to be very simple

ob_start();
include('file.php');
$fileContent = ob_get_contents();
ob_end_clean();

....

Thursday, May 6, 2010

Coldfusion 9 ORM – Configuring Existing Database

Working with Coldfusion 9 and was very exited to begin using it, first experiment to configure existing database




Step 1 – Enable ORM and Define your database



Application.cfc



Component {

this.name = “dashboards”;

this.ormenabled = “true”;

this.datasource = “mycy”;

}

Step 2. Add your existing table properties, here I am considering table named “reportsdata”

reportsdata.cfc

/**

* @persistent

*/

Component

{

property name=”reportdataid” fieldtype=”id” generator=”increment”;

property reportdataname;

property reportdatavalue;

property adddate;

property addby;

property moddate;

property modby;

}

That’s all, now we can test it out

test.cfm

<cfscript>

reportData = EntityLoadByPK(“reportsdata”,40);

writedump(reportData);

</cfscript>

Wednesday, February 3, 2010

Check out Save Our Tigers | Join the Roar

Title: Save Our Tigers | Join the Roar
Link: http://gotaf.socialtwist.com/redirect?l=498502890704838390471

Saturday, January 16, 2010

KSRTC - Bangalore to Coorg Online Booking

I was looking for a bus booking from Bangalore to Coorg and was really happy to find lots of post which said you can book it at http://www.ksrtc.in/.

The sign up process at http://www.ksrtc.in/ was really fast, but their search feature sucks, and I was not able to find any bus service from Bangalore to Coorg, I also tried, Bangalore - Madikeri and Bangalore - Kodagu but NO results. Finally I tried Bangalore to Virajpet, as I know that Virajpet is very close to Coorg. That search gave me the name "MERCARA", which is COORG.

So if you are looking to book tickets to Coorg on KSRTC, then search for BANGALORE to MERCARA. You will find A/C busses operating to and fro. Another strange thing on KSRTC is that if you are booking a return ticket, then your return journey can only be 5 days ahead, otherwise you cannot book return ticket !

Notes - wikipedia page -- http://en.wikipedia.org/wiki/Madikeri