By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,610 Members | 2,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,610 IT Pros & Developers. It's quick & easy.

Filtering form data.

P: n/a
Good day to all.

I have this problem in JavaScript. I have a form (textbox) which
accepts a series of numbers in format 9999-9999-9. Now i want to
filter all inputs to the textbox. let's say 1234-1234-1 is a valid
input, 12345-123-2 is an invalid input. I had a sample in filtering
email address. I used a filter on that one.

Hope anyone in the group can help me in my problem.
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Aionius wrote:
Good day to all.

I have this problem in JavaScript. I have a form (textbox) which
accepts a series of numbers in format 9999-9999-9. Now i want to
filter all inputs to the textbox. let's say 1234-1234-1 is a valid
input, 12345-123-2 is an invalid input. I had a sample in filtering
email address. I used a filter on that one.

Hope anyone in the group can help me in my problem.


If you want to require ####-####-#, the simplest way is 3 input boxes,
and you insert the dashes where you want them. Or, just one input box
that allows 9 digits, then you split it like you want.
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #2

P: n/a
JRS: In article <31**************************@posting.google.com >,
dated Thu, 19 Aug 2004 16:02:04, seen in news:comp.lang.javascript,
Aionius <ai*****@hotmail.com> posted :
I have a form (textbox) which
accepts a series of numbers in format 9999-9999-9. Now i want to
filter all inputs to the textbox. let's say 1234-1234-1 is a valid
input, 12345-123-2 is an invalid input.


/^\d\d\d\d-\d\d\d\d-\d$/

<URL:http://www.merlyn.demon.co.uk/js-valid.htm>

If the data is supplied and used elsewhere as dddd-dddd-d, then it will
be easier for the operative to insert it in that form; I would not
choose to split it into three boxes.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #3

P: n/a
Aionius wrote:
I have this problem in JavaScript. I have a form (textbox) which
accepts a series of numbers in format 9999-9999-9. Now i want to
filter all inputs to the textbox. let's say 1234-1234-1 is a valid
input, 12345-123-2 is an invalid input. [...]


if (/^\d{4}-\d{4}-\d$/.test(inputStr))
{
// valid input
}
else
{
// invalid input
}
PointedEars
--
Better living through chemistry...
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.