Results 1 to 8 of 8
  1.    #1  
    is it possible to have integers only allowed to be typed into a field? (answer = yes) if i can't find anything in the API's will i just have to code it in error checking?
  2. #2  
    CodeToad - Javascript Isnumeric function.

    Just use with an event, not extraordinarily efficient, but it'll do the job.


    You could also use an event which grabs the last index of the string and sees if it's 0-9.
  3.    #3  
    Yea i figured i might have to do error checking afterwords but wanted to nip it in the bud from the start while inputting into the txt field

    I've also seen isNaN() used.. maybee i'll go that route

    thanks!
  4. #4  
    Put
    Code:
    charsAllow: function( charCode ) { return(charCode >= 48 && charCode <= 57); }
    in your texfield's attributes

    for example:
    Code:
    this.controller.setupWidget("mainTextField",
    			{
    				maxLength: 1,
    				modifierState: Mojo.Widget.numLock,
    				focusMode: Mojo.Widget.focusSelectMode,
    				charsAllow: function( charCode ) { return(charCode >= 48 && charCode <= 57); }
    			},
    			this.amountModel = {
    				value: ""
    			}
    the above allows you to enter only numbers, automatically turns the number buttons on, and only allows 1 digit.
    danNielson.com - Slalom - twitter - facebook
    A posted thanks dies with the thread. Clicking the button lasts until the admins get bored with this site and throw it in the recycling bin.
  5.    #5  
    thanks i'll give it a shot a little later... today turned out to be a beach day!
  6.    #6  
    just wanted to say this worked perfectly... i also added the "." period to it as i wanted one field to have a percent.

    charCode >= 48 && charCode <= 57 && charCode = 46


    Again thanks!

    On to formatting! lol
  7. #7  
    In combination with the char methods above, use modifierState: Mojo.Widget.numLock so the user is already in numeric mode when they focus on the field.
    My apps:
    ReWeather - Attractive weather app that reflects current conditions
    Suburbly UK (trial version) - Search for properties to rent, share or buy all over UK.

    Twitter: @joshsharp / @recursivemedia
  8. #8  
    @josh, you didn't read the code snippet did you? modifierState is in there.
    danNielson.com - Slalom - twitter - facebook
    A posted thanks dies with the thread. Clicking the button lasts until the admins get bored with this site and throw it in the recycling bin.

Posting Permissions