[Javascript] Is Numeric Function
TomMallard
mallard at serv.net
Sun Feb 22 09:34:23 CST 2004
First, looked it up and the "-" is illegal for variable names in js,
underscore or letter first.
If you add a space to your pattern, is the space significant? So if you have
333 333, is that 333333 as a value or does the space mean something? If a
space means something then you have "coded" data, not just numeric, so,
that's important to document 'cause it's a pain to keep track of and causes
all kinds of errors down the stream...
hth,
tom mallard
seattle
-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu]On Behalf Of Peter Brunone
Sent: Friday, February 20, 2004 8:48 AM
To: '[JavaScript List]'
Subject: RE: [Javascript] Is Numeric Function
What about just "0123456789.()- "; ?
\n is a newline character, as in when you hit the Enter key.
Spaces are string characters just like (almost) everything else. If a
simple space in the string doesn't work, try escaping it as in "\ ".
Cheers,
Peter
-----Original Message-----
From: javascript-bounces at LaTech.edu On Behalf Of Grinwald, Uri
Thanks Peter.
What I was trying to say with my first question was the following. This
line in the function --> var ValidChars = "0123456789.()-"; How can I
add an empty space as valid? I tried \n but that did not work.
Thanks,
Uri
-----Original Message-----
From: Peter Brunone [mailto:peter at brunone.com]
Hi Uri,
I'm not exactly sure what you're asking in your first question,
but to replace in Javascript, you should be able to use
myString.replace(" ", "-");
Cheers,
Peter
-----Original Message-----
From: javascript-bounces at LaTech.edu On Behalf Of Grinwald, Uri
Hi List Members.
I have a function that checks for numbers:
It won't allow for space, so I need to either reflect that an empty
character is allowed within the function.
On a separate use of this function how can I replace any empty spaces
with a "-"
Here is my function at the top of page.
I call all my validations further down with a validate(obj) function.
function IsNumeric(passedVal)
{
var ValidChars = "0123456789.()-";
var IsNumber=true;
var Char;
if(passedVal == "")
{return false;}
for (i = 0; i < passedVal.length && IsNumber == true; i++)
{
Char = passedVal.charAt(i);
if (ValidChars.indexOf(Char) == -1)
{
IsNumber = false;
}
}
return IsNumber;
}
////and later I do the following...
if(!IsNumeric(obj.dynTelEng_11.value))
{
msgError = msgError + '\n' + 'Telephone Number must be numeric';
}
Etc...
Any help would be greatly appreciated.
Uri
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list