PDA

View Full Version : Problem with the issue of DateField and VType



livinglegends
17 Sep 2010, 12:24 AM
Hi,

I am using DateField in my application. Now, I want to restrict my date field to mm/dd/yyyy format and I have set following VType with DateField



var date_DDMMYYYY_Test = /^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[0-1])\/(19|[2-9][0-9])[0-9]{2}$/;
Ext.apply(Ext.form.VTypes, {
// vtype validation function
date_DDMMYYYY: function(val, field) {
if (date_DDMMYYYY_Test.test(val)) {
return true;
} else {
return false;
}

},
date_DDMMYYYYText: 'Not a valid date. Must be in the format MM/dd/yyyy.',
date_DDMMYYYYMask: /[0-9\/]/
});
As per above format, user cannot select year less than 1900. But, I want to allow user to select any year of 4 digits. So, to remove this restriction, I have changed date_DDMMYYYY_Test to below


var date_DDMMYYYY_Test = /^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[0-1])\/([0-9][0-9])[0-9]{2}$/; But its not working properly.

So, please help me to write format pattern so I can select any user.

Thanks in advance
Living Legend

laurentParis
17 Sep 2010, 7:55 AM
var date_DDMMYYYY_Test = /^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[0-1])\/[0-9]{4}$/;