Re: How do I make these into a real type?
[ Follow Ups ] [ Post Followup ] [ Intranet eXchange ] [ IDM Home ]
Posted by Jon Hanlon on August 24, 2000 at 19:30:36:
In Reply to: How do I make these into a real type? posted by Chris Davies on August 24, 2000 at 13:14:37:
Use the parseFloat method, once you've ascertained that the string is a valid real number: function whatAmI(str) { var reWhitespace = /^\s+$/ var reLetter = /^[a-zA-Z]$/ var reAlphabetic = /^[a-zA-Z]+$/ var reAlphanumeric = /^[a-zA-Z0-9]+$/ var reDigit = /^\d/ var reLetterOrDigit = /^([a-zA-Z]|\d)$/ var reInteger = /^\d+$/ var reSignedInteger = /^[+-]?\d+$/ var reReal = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/ var reSignedReal = /^(([+-]?\d+(\.\d*)?)|([+-]?(\d*\.)?\d+))$/ if (reAlphanumeric.test(str)) alert("Alphanumeric "); if (reReal.test(str)) alert("Real "); if (reSignedReal.test(str)) alert("SignedReal"); // etc... }
Follow Ups:
|