Tag Archives: jquery

Added valid date validation in jQuery validator

Recently I got lots of error on mobile page, where I cannot give a nice date picker.
I use jQuery validator for form validations, but its date validation is not validating valid date.

If you use the new Date() function with 32nd as date, then it takes next month’s date.

I came up with adding more validations in default date validation method.

(function($) {
	 * This is a date validation fix,
	 * Because earlier it was validating invalid dates like '12//2/12' or '04/31/2012'
	 * Edit 1: Added year range: 1012 is invalid year, SQL datetime range is 1/1/1753 TO 12/31/9999
	 $.validator.addMethod("date", function(value, element) {
		return this.optional(element) || (/^\d{2}([\/])\d{2}\1\d{4}$/.test(value) && !/Invalid|NaN/.test(new Date(value)) && parseInt(value.match(/^\d{2}/)) == (new Date(value).getMonth()+1) && parseInt(value.match(/\d{4}/)) > 1752);

Save the above code in one js file e.g. jquery.validate.datefix.js and include it after you include jQuery validator js.

Enable/disable link button in jquery Mobile


I am developing mobile application, where I use jquery Mobile.

Buttons can be created by input tag, button tag and even link tag. See examples:


<input type="button" value="Button2" />

<a href="#" data-role="button">Button3</a>

In docs, I see enable/disable method for button. See.

But using this method, it can only set style, functionally it doesn’t! May be they missed it!

Anyway, I got some trick to make link enable/disable.

HTML5 now has data attribute that user can use it, browser will ignore it while rendering it.

So Disabling a link, I just remove href and onclick value to some data attribute and vice versa.

function test(){
    if ($("#mytest").parent().attr("aria-disabled") == "true") {
      $("#mytest").attr("href", $("#mytest").attr("data-href"));
      $("#mytest").attr("onclick", $("#mytest").attr("data-onclick"));
    } else {
      $("#mytest").attr("data-href", $("#mytest").attr("href"));
      $("#mytest").attr("data-onclick", $("#mytest").attr("onclick"));

See live example here.

Source code here.

jQuery Mobile will now support BlackBerry 5.0

Hi guys,

I am working on a huge business application. Currently major work is done by web application built on ColdFusion. But now we have created iPhone and Android application. Both are built on native platform, but now we can’t ignore blackberry and Symbian OS users.

So we’ve decided to work on platform independent framework, and that is PhoneGap.

I tell you that jQuery Mobile are working so hard that they differentiated touch, click swipe events very nicely. So I strongly recommend both the framework for your mobile application.

Coming to the title point, jQuery Mobile gave B grade the BlackBerry OS 5.0 native browser, as it lacks some of the important features. But as of now there are about 50% blackBerry users have OS 5.0. So while developing an business application, we can’t exclude them, so I decided to start working on the issues and try to remove them.

First of all, I realize that BlackBerry 5.0 browser doesn’t support URL hash change event. and it is a main disaster for JQM. So I and eventually JQuery Mobile team thought that, we should remove ajax call for BB5, and they made it! Excellent huh!.

Enjoy Mobilisum!