Hi!
I'm not that good in Javascript but maybe this could work:
say str is your string:
var str="0123 4-567 89";
for(i=0, ncount=0;i<str.length;i++)
{
if( str.charAt(i) >= '0' && str.charAt(i) <= '9' )
ncount = ncount + 1;
else
if( str.charAt(i) != ' ' && str.charAt(i) != '-')
alert("no letters allowed, except '-' and blank");
}
if(ncount != 10)
alert("please enter 10 numbers!");
i hope i helped you
----- Original Message -----
From: "Martin Nadoll" <ma****@nadoll.de>
Newsgroups: comp.lang.javascript
Sent: Thursday, October 30, 2003 5:35 PM
Subject: form field validation
Hello,
i have a few problems with form field validation:
First i have to check, wether a field is filled with 10 integer numbers.
Also allowed is " " and "-" but no letters, and the input of numbers must
be ten e.g.
"123456-78-9 0" should be allowed and also "12 34 67 67---56" also,
but not "123456789". This should show a alert-message.("Please enter 10
numbers").
Is there any help for me?
Thanks a lot,
Martin Nadoll