Numeric Only Editbox
Posted by snang
Tuesday, May 30, 2006
Description: Used for dialog editboxes

You can use this code to restrict access in a dialog editbox to numeric only.  I suppose you could alter it to prevent entry of numbers?

But here you go.

Obviously you'll need to adjust the dialog name and ID.

on *:DIALOG:<dname>:edit:<id>: {
  if ($right($did($dname,$did).text,1) !isnum) {
    did -o <dname> <id> 1 $left($did($dname,$did).text,$calc($len($did($dname,$did).text) - 1))
    did -a <dname> <id> $null
  }
}
Hmm.
Posted by snang
Tuesday, May 30, 2006 04:35pm PDT
It wrapped the code, line 4 is the end of line 3.
No numbers
Posted by snang
Tuesday, May 30, 2006 04:37pm PDT
Yes, it can be changed to disallow the entry of numbers.  Obviously just change the !isnum, to isnum.
Wrap
Posted by rayeh
Tuesday, May 30, 2006 04:39pm PDT
It's only a virtual wrap fortunately, copying and pasting it will result in a normally formatted script.
My version
Posted by poiuy_qwert
Tuesday, May 30, 2006 04:50pm PDT
Not tested.


on *:DIALOG:<dialog>:*:*:{
  if ($devent == edit) && ($did == <id>) {
    if (!$hget($dname,$did)) hadd -m $dname $did $null
    if ($did($dname,$did) !isnum) did -ra $dname $did $hget($dname,$did)
    else hadd $dname $did $did($dname,$did)
  }
  elseif ($devent == close) && ($hget($dname,$did)) hdel $dname $did
}
Submit a comment
Oops! You need to login or register before you can post a comment!

ebaum's world