realbasic-nug
[Top] [All Lists]

Field validation

To: REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Field validation
From: Brian Seavers <brian at bsweb dot co dot uk>
Date: Fri, 28 Jun 2002 19:31:14 +0100
Hi everyone

This MUST have been covered many times, but I haven't been able to find it through the archives.

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 ?

Thanks

Brian
--


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