Best way to restrict a text field to numbers only?

This is something I made another time for just numbers, it will allow all the formatters as well. jQuery $(‘input’).keypress(function(e) { var a = []; var k = e.which; for (i = 48; i < 58; i++) a.push(i); if (!(a.indexOf(k)>=0)) e.preventDefault(); });​ Try it http://jsfiddle.net/zpg8k/ As a note, you’ll want to filter on submit/server side … Read more

Why are some textboxes not accepting Control + A shortcut to select all by default

You might be looking for the ShortcutsEnabled property. Setting it to true would allow your text boxes to implement the Ctrl+A shortcut (among others). From the documentation: Use the ShortcutsEnabled property to enable or disable the following shortcut key combinations: CTRL+Z CTRL+E CTRL+C CTRL+Y CTRL+X CTRL+BACKSPACE CTRL+V CTRL+DELETE CTRL+A SHIFT+DELETE CTRL+L SHIFT+INSERT CTRL+R However, the … Read more

WPF: How can I stretch the middle child in a DockPanel?

You need to set DockPanel.Dock attached property for your elements and leave TextBox as the last element: <RadioButton HorizontalAlignment=”Stretch” HorizontalContentAlignment=”Stretch”> <DockPanel LastChildFill=”True”> <TextBlock DockPanel.Dock=”Left” VerticalAlignment=”Center” Text=”in location:” /> <Button DockPanel.Dock=”Right” Margin=”10,0,0,0″ Padding=”3,0″ Content=”…” /> <TextBox Margin=”10,0,0,0″> Path string </TextBox> </DockPanel> </RadioButton>