1. #1
    Sencha User
    Join Date
    Mar 2011
    Posts
    15
    Vote Rating
    0
    giehl is on a distinguished road

      0  

    Default [Solved]Textfields for specific Character

    [Solved]Textfields for specific Character


    How to setting textfields that can only be edited by a specific character?
    (ex. number)

    Solved: Iam using this code for textfield
    Code:
    maskRe: /^([0-9])$/
    Thanks for "skirtle"
    Last edited by giehl; 19 Jun 2011 at 2:02 AM. Reason: solved

  2. #2
    Sencha User skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,338
    Vote Rating
    248
    skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of

      0  

    Default


    This is covered in the introduction in the docs:

    http://dev.sencha.com/deploy/ext-3.4...form.TextField

    maskRe and stripCharsRe.

    If you're specifically interested in numbers then see:

    http://dev.sencha.com/deploy/ext-3.4...rm.NumberField

    If you click the 'Hide Inherited Members' button (blue up arrow with red minus, top-right toolbar) it'll show you specific settings for number configuration.

  3. #3
    Sencha User
    Join Date
    Mar 2011
    Posts
    15
    Vote Rating
    0
    giehl is on a distinguished road

      0  

    Default


    I was used numberfield before, but when I entry data like this "196411051990031003" it goes "196411051990031000".
    003 to 000, any advice? And how to make textfield just for number character?



    Thanks

  4. #4
    Sencha User skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,338
    Vote Rating
    248
    skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of

      0  

    Default


    You cannot represent such large integers precisely using numbers in JavaScript, as you've observed you get rounding. Do you really need such big numbers? If you do then you'll need to keep them as strings.

    As for implementing your own number-only TextField, I suggest you have a read of the source code for NumberField:

    http://dev.sencha.com/deploy/ext-3.4...ield-baseChars

    The initEvents() method is particularly relevant but all it does is use the config options I mentioned previously.

  5. #5
    Sencha User
    Join Date
    Mar 2011
    Posts
    15
    Vote Rating
    0
    giehl is on a distinguished road

      0  

    Default


    But, how I can implement textfield for number with baseChars?

  6. #6
    Sencha User skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,338
    Vote Rating
    248
    skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of

      0  

    Default


    Just use a maskRe of /\d/ and a stripCharsRe of /^\D*0+(?=.*\d)|\D/g.
    Last edited by skirtle; 18 Jun 2011 at 10:13 AM. Reason: Revised stripCharsRe to handle zeros and copy/paste text better.

  7. #7
    Sencha User
    Join Date
    Mar 2011
    Posts
    15
    Vote Rating
    0
    giehl is on a distinguished road

      0  

    Default


    Quote Originally Posted by skirtle View Post
    Just use a maskRe of /\d/ and a stripCharsRe of /^\D*0+(?=.*\d)|\D/g.
    Hows that work? When I implemented that, just char "d" that I can typed...

  8. #8
    Sencha User skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,338
    Vote Rating
    248
    skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of

      0  

    Default


    \d matches a numeric digit whereas just d would match the letter d, I can only assume you've typed it in wrong. Regular expressions are bread-and-butter programming, please read a tutorial so that you can fix trivial mistakes like this by yourself.

    Try copy and paste to make sure you type it in right:

    Code:
    new Ext.form.TextField({
        maskRe: /\d/,
        renderTo: Ext.getBody(),
        stripCharsRe: /^\D*0+(?=.*\d)|\D/g
    });

  9. #9
    Sencha User
    Join Date
    Mar 2011
    Posts
    15
    Vote Rating
    0
    giehl is on a distinguished road

      0  

    Default


    I was followed ur advice, but it same as before.

  10. #10
    Sencha User skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,338
    Vote Rating
    248
    skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of

      0  

    Default


    The only thing I can think of is that whatever browser you are using doesn't support \d and \D. I can't find any mention of this online, nor do any of the browsers I have exhibit this problem, including IE6.

    On the off chance it is that, you could use the character classes of [0-9] and [^0-9] to replace them. I repeat, please read a tutorial.

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar