Simple example
In the first example, we will create a form, and initialise the datepicker widget. It should be noted that you can do many more things than just
form widgets and validation with PAX, but this makes a fine first example.
We start with a simple form:
<form name='valForm' method='post'>
<label for='name'>Name</label><input name='name' id='name' type='text' value=''/><br/>
<label for='dob'>Date of birth</label><input name='dob' id='dob' type='text' size='30' value=''/><br/>
<label for='city'>City of birth</label><input name='city' id='city' type='text' value=''/><br/>
</form>
<label for='name'>Name</label><input name='name' id='name' type='text' value=''/><br/>
<label for='dob'>Date of birth</label><input name='dob' id='dob' type='text' size='30' value=''/><br/>
<label for='city'>City of birth</label><input name='city' id='city' type='text' value=''/><br/>
</form>
You should note the use of a conditional y offset for the button, (for Internet Explorer), this feature is in recognition that CSS is often not standard across browsers, and in our case, IE's interpretation of it is a bit different to other browsers. This is an easy way to get around such issues:
pax.load.onloaded( function() {
pax.widget.datePick.init( pax.$('dob'), {
dateFormat: 'd-m-Y',
buttonOffset: { y: (pax.isIe)? -9: 0 }
} );
} );
pax.widget.datePick.init( pax.$('dob'), {
dateFormat: 'd-m-Y',
buttonOffset: { y: (pax.isIe)? -9: 0 }
} );
} );
Now you're probably wondering: what the heck is "pax.load.onloaded"? Well, when you load a HTML page into a browser, you must wait till the DOM has loaded, before executing DOM based scripting. As such, PAX has a small function to do this for us.
Well, that example wasn't too hard, was it!? Read on for a more substancial example!




