[thelist] js validating numbers

Erik Mattheis gozz at gozz.com
Tue Feb 11 10:03:20 CST 2003


oops reread message ... sorry ....  try:

function returnTypeOfNum(chk) {
   if (parseInt(chk) == chk) {
     return 'integer';
   else if (!isNaN(chk)) {
     return 'decimal number';
   }
   else {
     return 'no sort of number';
   }
}

but still not sure what you mean by:

> Should they be forced to enter 2.00
> for 2%? How would I manage forcing a percentage?

What would the question be that could be answered by a number or
percentage that would be meaningful without the user indicating so?

On Tuesday, February 11, 2003, at 08:22  AM, Tom Dell'Aringa wrote:

> Hello,
>
> I am working on a form where I have to validate some fields to make
> sure the values entered are numeric. I have this function which does
> work:
>
> ========================================
> function IsNumeric(strString)
> {
> 	var strValidChars = "0123456789.-";
> 	var strChar;
> 	var blnResult = true;
>
> 	//  test strString consists of valid characters listed above
> 	for (i = 0; i < strString.length && blnResult == true; i++)
> 	{
> 		strChar = strString.charAt(i);
> 		if (strValidChars.indexOf(strChar) == -1)
> 		{
> 			blnResult = false;
> 		}
> 	}
> 	return blnResult;
> }
> =====================================================
>
> However, it looks like they want me to validate 2 types of numbers: 1
> - that its a number, and 2 - that its a *percent* (i.e., 5.76) or
> floating point. I'm not sure my function is sufficient for this
> second part..what do you think? Should they be forced to enter 2.00
> for 2%? How would I manage forcing a percentage?
>
> Tom
>
> =====
> var me = tom.pixelmech.webDeveloper();
>
> http://www.pixelmech.com/
> http://www.maccaws.com/
> [Making A Commercial Case for Adopting Web Standards]
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Shopping - Send Flowers for Valentine's Day
> http://shopping.yahoo.com
> --
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>
>
-----------------------
Erik Mattheis
GoZz Digital
<http://goZz.com/>
Flash and ColdFusion Development
Minneapolis, MN
-----------------------




More information about the thelist mailing list