10 Nov 2010 6:40 AM #1
How to restrict a user to type only certain characters in the text field
I need a text field where a user can type only certain characters like number field does where user can enter only numbers and dot.
I tried with setting the regex for the text field but it allows user to type other characters and on blur it shows validation message. But I don't even want to allow the user to put other characters in it.
Is there any way to get this?
Any help will be appreciated.
10 Nov 2010 6:41 AM #2
Take a look at the numberfield sources how it is archieved there.
Basicly it listens for the keypress event, checks the key and if it is a not allowed one, you have to prevent the default action.
14 Aug 2012 3:41 AM #3
My requirement is , the text field should only accpet the numbers..
any help is apreciated
14 Aug 2012 11:53 PM #4
If you only want to receive number value, why not using NumericField.
Only maybe you add a Listener to your TextField, and do some logic code to meet your requriements!
By Rodkun in forum Ext 1.x: Help & DiscussionReplies: 1Last Post: 17 Feb 2009, 7:18 PM
By prext in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 20 Jan 2009, 8:44 PM
By ajax&me in forum Ext 2.x: Help & DiscussionReplies: 5Last Post: 29 May 2008, 9:30 AM
By c_ankit in forum Ext 2.x: Help & DiscussionReplies: 0Last Post: 12 Jan 2008, 9:30 AM