Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2004
    Location
    Belgium, Leuven
    Posts
    145

    how to avoid space in input field

    All,

    I'm trying to make a small app that allows people to enter text in an input box.
    I want to avoid that some characters are use (? * \ / ...). I can do this by using the input mask ?????????

    I also want to avoid the SPACE to be entered. I did not see an option to do this.

    So I tried to use FIND on the string, but for a reason I do not understand the space is always found as the last character, even when it was not entered.

    Does anyone have a solution for this? Or, is my observation wrong?

    thanks

    gert

  2. #2
    Join Date
    May 2006
    Posts
    5,380
    http://www.indigorose.com/forums/sho...ght=filter+key

    Edit:

    in AMS 7.5 use the below function

    Code:
    function FilterKeyPress(InputObject, e_Key, sAllowed)
    	sOrig = Input.GetText(InputObject)
    	sFilter = String.TrimLeft(sOrig, sAllowed)
    	sFilteredLeft = String.TrimLeft(sOrig, sFilter)
    	sFilteredRight = String.TrimRight(sFilteredLeft, sFilter)
    	Input.SetText(InputObject, sFilteredRight)
    	Input.SetSelection(InputObject, String.Length(Input.GetText(InputObject)) + 1, String.Length(Input.GetText(InputObject)))
        Input.SetSelection(InputObject, -1, 1)	
    end
    Last edited by RizlaUK; 10-11-2009 at 04:44 AM.
    Open your eyes to Narcissism, Don't let her destroy your life!!

  3. #3
    Join Date
    Nov 2004
    Location
    Belgium, Leuven
    Posts
    145
    whaw.... This is a very usefull trick!
    thanks a lot.

    gert

  4. #4
    Join Date
    Oct 2004
    Location
    East, South & West Asia
    Posts
    1,020

    REGEX - Regular Expression

    Hi Gert,

    You have another option that you can use together.

    I have an example in my website to filter out any character (including space) that you want from user submissions.

    The function is like a REGEX ( regular expression ).

    You can adjust the function for various kinds of INPUT:
    1. Numbers only
    2. Alphabets only
    3. Alphanumerics only
    4. Alphanumerics + other DEFINED characters
    5. Correct positions and number of defined characters
    6. etc for whatever you fancy.

    When user submit, the input will be checked and prompted with advice to correct specific errors, if any.
    Newbie Examples
    ------> AMS 7.5 : amstudio.azman.info
    ----> AMS 6 & 5: www.azman.info/ams/
    ----> FB: facebook.com/GuideToWealth

    ----> Content Development Blog: www.AZMAN.asia

  5. #5
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    beware of cut and paste. It doesn't fire the keypress event. You'll need to parse that differently.

  6. #6
    Join Date
    Nov 2004
    Location
    Belgium, Leuven
    Posts
    145
    Worm, right! I discovered that one as well, so I check the fields before I allow the OK button to be clicked.


    thanks

    gert

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts