validationextjslocalecjktimefield

Why does the default ExtJs time field validation fails with other locale (Chinese)?


I use the zh_CN locale in ExtJs (ExtJs 4.0), the default locale files that ship with ExtJs (no modifications made to it). When I use a timefield in my form, I get a validation error for any value by default. Only if I use the English AM/PM, or if I remove the 上午/下午 manually at the end, it works ok. I would assume ExtJs would be smart enough to handle the different locales correctly. Do I really need to define my own Regex, MaskRe here? Or how to solve this otherwise? Thanks! I'm fairly new to ExtJs.

The field definition:

{
xtype: 'timefield',
name: 'pickupDate',
fieldLabel: lang["patient.pickup_time"],
allowBlank: true
}

enter image description here


Solution

  • The TimeField validation isn't really all that fancy -- it does not attempt to handle every possible locale-specific time format. You'd need to override the default time formats as needed for your case by specifying the Time field's format and/or altFormats configs.