Home › Forums › General XMetaL Discussion › Xmetal to check numeric value and alphanumeric value › Reply To: Xmetal to check numeric value and alphanumeric value
Reply to: Xmetal to check numeric value and alphanumeric value
November 23, 2012 at 6:52 pmThis isn't really an XMetaL or XFT question, it is more a JScript question (for which there are lots of different answers and resources). There is no “XMetaL JScript”. XMetaL uses the standard JScript engine installed with your copy of Windows, so you can use any of the resources that talk about using JScript on Windows (including Microsoft's documentation), the same engine used by Internet Explorer.
To start, JScript has a function called isNaN() that you can use to check for “non numbers”, however, it is quite simplistic and possibly won't meet your needs. Its main use is to check if something is a number before feeding it into some JScript math expression so that the expression won't fail. However, JScript can convert some things into numbers that you might not expect.
Your best bet is a regular expression. You might start here:
http://msdn.microsoft.com/en-us/library/28hw3sce%28v=vs.80%29.aspx
http://www.w3schools.com/jsref/jsref_obj_regexp.asp
http://stackoverflow.com/questions/18082/validate-numbers-in-javascript-isnumeric