-
27 Aug 2007 8:06 AM #1
Time field
Time field
Hello,
I need to allow the user to insert a date and time in a form. DatePicker is perfect for this, but I need the time widget. Can you suggest how to do it?
The simpler way is to use a text field, but I'd like to have something fancier.. Perhaps to allow the user to enter time with or without seconds, or some graphic knob to pull..
Do you think it would be better to use 3 numeric fields instead of a text one? Or perhaps a combo box for hour, minutes and seconds? Do you have a piece of code you'd like to share?
Thanks a lot!
-
27 Aug 2007 7:04 PM #2
Yes, is there any samples on Time selecting field, similar with DateField?
Thanks!
-
27 Aug 2007 8:03 PM #3
There is a simple TimePicker in 2.0 (in SVN). It's a combo field that allows typing directly or choosing from the list. Unfortunately there's nothing in 1.x for this.
-
27 Aug 2007 8:10 PM #4
As far as version 1 goes, I think the simplest solution to this would be a standard TextField element with the config options set like
(please forgive the regular expression if it isn't quite right... I haven't checked it, but it gives you a good idea of what to do)Code:emptyText: "HH:MM:SS", maskRe: "^[0-9]{1,2}:[0-9]{2}(:[0-9]{2})?$"
If you have those set, you can let the users know what goes in there and also keep them from entering anything that shouldn't be there in the first place with the validation that's built into the Ext forms.
-
27 Aug 2007 10:41 PM #5
Is version 2.0 already usable or it is still very buggy?
At the moment I've decided to go for a text field. This is my VType:
I'd like to limit the numer of characters that can be entered in the TextField, I've used maxLength but it is not exactly what I wanted, since the user can still enter more characters and they are checked as validation. Instead I'd like to limit the number of characters when typed. How do I do it?Code:Ext.form.VTypes["timeVal"] = /^(0{0,1}[0-9]:[0-5][0-9]|1[0-9]:[0-5][0-9]|2[0-3]:[0-5][0-9])(:[0-5][0-9])?$/; Ext.form.VTypes["time"]=function(v){ return Ext.form.VTypes["timeVal"].test(v); } Ext.form.VTypes["timeText"]="Insert a valid time in the format HH:MM or HH:MM:SS"; Ext.form.VTypes["timeMask"]=/[:0-9]/;
Thanks!


Reply With Quote