Filtering form data.

A

Aionius

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.
 
R

Randy Webb

Aionius said:
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.
 
D

Dr John Stockton

JRS: In article <[email protected]>,
dated Thu, 19 Aug 2004 16:02:04, seen in
Aionius said:
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.
 
T

Thomas 'PointedEars' Lahn

Aionius said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top