PDA

View Full Version : I've forgotten how to get a field to allow only integers


Vlad
12-19-2002, 06:01 PM
I have a text field in the form I am working on, and I can't remember the string to have the form only allow integers and keep you from inputing other characters...can you help me out?

krycek
12-19-2002, 06:12 PM
you can't without writing some JavaScript validation :)

beetle will be along in a minute flogging his fValidate to death :D

if you want, go and look for him coz he has a link in his sig, just find one of his many posts lol ;)

::] krycek [::

beetle
12-19-2002, 06:21 PM
Originally posted by krycek
beetle will be a long in a minute flogging his fValidate to death :DDamn skippy!

Psssst! The link is over ----> here (http://www.peterbailey.net/fValidate) <----

Or right down there

----------\/

Vlad
12-19-2002, 07:01 PM
thank you very much! :D that was exactly what I was looking for!

Nice site, by the way ;)

krycek
12-19-2002, 07:20 PM
heheh :) you can pay me later beetle ;)

::] krycek [::

Skyzyx
12-20-2002, 01:47 AM
You guys... :rolleyes:

whammy
12-20-2002, 01:54 AM
Well... I would give a couple of examples of how to not allow someone to type anything but digits in a field using event.keyCode and event.which, and then to make sure that "onblur" anything but digits was erased... but I guess there's no point now.

I'll at least give an example of the latter... ;):

<input type="text" name="blah" onblur="this.value=this.value.replace(/\D/g,'')" />

:D

P.S. I am not trying to make people avoid fValidate - but for those who do want to understand it on their own, I make this post. ;)

Regular Expressions rule - and they are something I think every developer should be familiar with!

chrismiceli
12-20-2002, 02:24 AM
reg expressiong rule, but i am still learning them, do you all know any good sites?

whammy
12-20-2002, 02:27 AM
Oh yeah...

http://developer.netscape.com/docs/manuals/js/client/jsguide/regexp.htm

http://www.siteexperts.com/tips/functions/ts23/page1.asp

Those should give you plenty of things to chew on, and a good foundation. :D

Don't forget to look at my signature and "google it" ;)

chrismiceli
12-20-2002, 02:30 AM
i love google, that is the first place i go everytime, i just wanted the opinion of this forum, thanx whammy :thumbsup: :) :thumbsup:

whammy
12-20-2002, 02:33 AM
Thank Karen Gayda (the second link) ;)

She explains this stuff pretty simply - once you digest that and play around with it a bit, take a look at the first link... regular expressions aren't hard at all (in most cases!), you just have to understand the syntax. :)

Vlad
12-20-2002, 04:26 PM
Actually, Whammy, I appreciate the input. It's nice to know how to do it without an outside form. I appreciate everyone's help!

beetle
12-20-2002, 05:16 PM
Originally posted by whammy
P.S. I am not trying to make people avoid fValidate - but for those who do want to understand it on their own, I make this post. ;)Don't sweat it dude. I don't.

Besides, fInteract (If I ever finish the thing) will add blur-style formatting like that, with NO extra coding if you're already using fValidate ;)

Geez, I need a PR guy....(j/k)

whammy
12-21-2002, 01:43 AM
An idea for you beetle - there may be cases where people want to check/uncheck a checkbox to clear/unclear a related field or fields... (I had to do something like that today at work).

Might be something else to play around with with fValidate (if you haven't already done so)... ;)

beetle
12-21-2002, 04:01 AM
That's fInteract's territory. fValidate will stick with just validation.