Restricting input to numbers and Dashes only

2 views
Skip to first unread message

Chuck

unread,
Sep 30, 2008, 4:44:57 PM9/30/08
to CenoPDF Support Group
I'm trying to restrict the entry to any number character and a dash
(or at the most 2 if possible)

the user is entering either a SS No, or A Entity ID number
(999-99-9999 or 99-999999) in the field.

I saw the entry for restricting characters in a text box, and instead
of having to enter every possible character on the keyboard I was
wondering it there was a way to only allow the indicated characters.

I tried something like this (I'm not really a java script progrmmer
tho)
for(;;)
{
var v = event.change.replace(1234567890-, "");
if(v <> event.change)
break;
event.change = v;
}

but of course that does't work. Do you have an example of how this
might be implemented.

Thanks for the program works great on Vista Ultimate 64bit with Office
2007.

Chuck Sndyer

CenoPDF Support

unread,
Sep 30, 2008, 5:10:50 PM9/30/08
to CenoPDF Support Group
Hello Chuck,

We are glad to know our software works for you. You can use the
following script:

for(;;)
{
var v = event.change.replace(/[^0-9\-]/, "");
if(v == event.change)
break;
event.change = v;
}

Note that [^0-9\-] is a regular expression. You can google for its
syntax. Basically that statement means if the input character is not
between 0-9 or "-", replace it with empty string.

Thanks,

-- CenoPDF Support
http://www.lystech.com

Chuck Snyder

unread,
Sep 30, 2008, 5:26:19 PM9/30/08
to cenos...@googlegroups.com
Didn't realize it was a reg expression.  That makes sense.
 
Thanks for the help, just placed the order.
 
chuck

Reply all
Reply to author
Forward
0 new messages