realbasic-nug
[Top] [All Lists]

Re: Field validation

To: REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Field validation
From: Kevin Ballard <kevin at sb dot org>
Date: Fri, 28 Jun 2002 14:38:56 -0400
On 6/28/02 2:31 PM, "Brian Seavers" <brian at bsweb dot co dot uk> wrote:

> I'm looking for simple editfield validation, i.e reject
> non-alphanumeric characters (and allow spaces !) as they are typed in
> an editfield.
> 
> I have placed the following code in the 'TextChange' event of the editfield :
> 
>  dim txt as string
> 
>  txt="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 "
> 
>  if instr(1,txt,mid(me.text,me.selstart,1))<1 then
>    me.text=replace(me.text,mid(me.text,me.selstart,1),"")
>    me.selstart=me.selstart-1
>  end if
> 
> Now... this IS working, but it is visibly slow (can see the 'replace'
> happen on my iMac 400 DVSE,[compiled!])...
> 
> There must be a neater way of doing this ! Any ideas ?

Try the KeyDown event instead, and Return True to block the keypress.

-- 
Kevin Ballard
kevin at sb dot org
Email from Korea or China must go to <kevin dot nb at sb dot org>
http://kevin.sb.org/



<Prev in Thread] Current Thread [Next in Thread>