While working with extjs date control , I experienced a lots of problems.
-Auto increment of date in extjs
take a look at
http://extjs.com/deploy/dev/examples/form/xml-form.html
In that example when u put some value like 13 in months field of date control then on shift of focus,date control gets auto incremented.I dont know how this can be useful to any one ?? So i felt like correcting this mistake of user rather notify him of his error.
so all i has to do is handle this function
Ext.form.DateField.prototype.beforeBlur = function() { };
and keep my custom validator in place
function dateValidator(value)
{
if((parseInt(value.substring(0,2)) <=0 ) || (parseInt(value.substring(0,2)) > 12))
{
var message= 'Please Enter a Proper Number for ' + ' Month ' +' in ' + this.fieldLabel+' field ';
return message;
}
else if((parseInt(value.substring(3,5)) <=0 ) || (parseInt(value.substring(3,5)) > 31))
{
var message= 'Please Enter a Proper Number for ' + ' Day ' +' in ' + this.fieldLabel+' field ';
return message;
}
else
return true;
}
-Keys inside Date Control
Another important feature i needed was to allow user to submit the forum on enter even when he was in date field and the important thing was to get the edited(dirty) value of date filed.
Normally when u apply key events for a form , try to submit that form say on Enter key , then when u 'enter' while focus inside date field then you end up getting the value of date field which may not be the exact value u have entered in currently focused date field .The way extjs does is
-value : proper value
-rawvalue : dirty value which may or may not be valid
So in my case of user entering while inside datefield, i use getRawValue().
Refer to example in attachment.
http://www.box.net/shared/lkal6x9sr7
No comments:
Post a Comment