Print Page | Close Window

Allow numbers only in textbox?

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: JavaScript
Forum Description: Discussions relating to the use of JavaScript within PDF.
Printed Date: 25 Feb 2020 at 1:23am
Software Version: Web Wiz Forums 11.10 -

Topic: Allow numbers only in textbox?
Posted By: mobius55
Subject: Allow numbers only in textbox?
Date Posted: 17 Oct 2011 at 2:52am
I'm trying to format a textbox to accept only numeric data - a 5-digit zipcode. I tried setting the data type to numeric, but I find that leading zeros (i.e. zipcode 07766) are being truncated (to 7766 in this case).

Can anyone suggest a javascript that could accomplish this validation? Tried doing something with (NAN) but my javascripting is, alas, pretty shaky :-o


Posted By: BAlheit
Date Posted: 17 Oct 2011 at 10:59am
You can use Zip Code as format:

Posted By: gkaiseril
Date Posted: 17 Oct 2011 at 2:49pm
If you access the zip code in another field with JavaScript, you will have to use the 'valueAsString' property to keep the leading zero.

Posted By: mobius55
Date Posted: 17 Oct 2011 at 6:28pm
Thanks to both of you. I had found the zipcode format option, but I'm having the same problem with telephone numbers, i.e. 201-888-0002. Didn't look for a phone number format but I will. Failing that, I'll look up the 'value as string' property, assuming I can use it as a validation code in one way or another.

Much appreciated!

Posted By: gkaiseril
Date Posted: 17 Oct 2011 at 6:55pm

Those predefined formats include, behind the scenes, special code for the inputted keystrokes, format, and validation. There is also an option for an arbitrary mask, see help for more information. If none of those work, then you need to write your own scripts using the RegExp object.

Posted By: mobius55
Date Posted: 17 Oct 2011 at 9:53pm
OK, I'll check it out! Thanx again!

Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 -
Copyright ©2001-2017 Web Wiz Ltd. -