extJS: VType for validating a time

I needed a VType for validating a time using the extJs framework in the format HH:MM (24 hour clock, no 'AM' or 'PM') and couldn't find one that quite fit the bill, so a tweaked version is:

Ext.form.VTypes["timeVal"] = /^([0-9]|1[0-9]|2[0-3]):([0-5][0-9])$/i;
Ext.form.VTypes["timeMask"] = /[\d\s:amp]/i;
Ext.form.VTypes["timeText"] = "Not a valid time.  Must be in the format hh:mm";
Ext.form.VTypes["time"] = function(v)
{
    return Ext.form.VTypes["timeVal"].test(v);
}

About Rob

I've been interested in computing since the day my Dad purchased his first business PC (an Amstrad PC 1640 for anyone interested) which introduced me to MS-DOS batch programming and BASIC.

My skillset has matured somewhat since then, which you'll probably see from the posts here. You can read a bit more about me on the about page of the site, or check out some of the other posts on my areas of interest.

No Comments

Add a Comment