Reply to Re: numeric checker

Your name:

Reply:


Posted by Neredbojias on 01/09/07 04:32

To further the education of mankind, "Tom" <someone@home.uk> vouchsafed:

> Being a newbie to JS, I would appreciate some advice. When a
> visitor enters a number into a textbox, I want to check that it is 15
> digits long and then display a message accordingly and the following
> script does that OK. However, I want also to make sure that only
> "numbers" are entered and no other characters. Again the attached
> does this but is clumsy to say the least! How do I get it to loop
> back to the input box if it contains a non-numeric, before it goes off
> to check for 15 digits?
(snip)
> Any help would be greatly appreciated.
> Tom

The easiest way is a regular expression match check for 15 numeric digits.

OTTOMH: var.match(/\d\d\\d\d\d\d\d\d\d\d\d\d\d\d\d/);

or

var.match(/\d{15}/);

--
Neredbojias
Infinity has its limits.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация