VB Script IsNumeric Function and the dollar sign

Hi - I have a classic ASP page that uses VBScript and I need some help.  

I have a form that allows a user to enter a budget amount.  I want to insure the value the user enter EXCLUDES the dollar sign ($) and the comma (,).  


$10,500.00 (False)

10500.00 (True)

I wrote this to test the value entered...

If NOT IsNumeric(strBudget) THEN
  ' message
End If

.... but IsNumeric allows the dollar sign and comma and returns True.  

Is there another function that I could use to test the value entered?  I want to make sure the user isn't entering a dollar sign or a comma.

Who is Participating?
Patrick MatthewsConnect With a Mentor Commented:
For more about using RegExp to validate entries in ASP:http://www.4guysfromrolla.com/webtech/120400-1.shtml
Patrick MatthewsCommented:
You may want to use Regular Expressions, and test on this pattern:^\d\.?\d*$
You will have to check for the existence of the "$" and "," on top of the IsNumeric check. Use the InStr function to do this: http://www.w3schools.com/VBscript/func_instr.asp
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

cdemott33Author Commented:
matthewspatrick - Can you provide an example of how I could do this?
If you could use javascript -

script would be this -
function validateNumberField (objEvent)
        var iKeyCode;
            iKeyCode = objEvent.charCode ? objEvent.charCode : objEvent.keyCode;
      if(iKeyCode>=48 && iKeyCode<=57) return true;
        if (iKeyCode == 8) return true;
        return false;

then your code would have something like this:
<input type="text" size=1 name="month" id="month" onKeyPress="return validateNumberField(event);">

and only allow numbers.
Patrick MatthewsCommented:
>>You will have to check for the existence of the "$" and "," on top of the IsNumeric checkAnd that's not all.  For example, these return true as well:IsNumeric(" 1234")IsNumeric("1234 ")IsNumeric(" 1234 ")RegExp is looking better and better :)
Patrick MatthewsCommented:
For an example, see:http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/ASP/Q_21591244.htmlNote that you should use the pattern string I supplied in my first comment...
cdemott33Author Commented:
Thank you.  Using a regexp match worked perfectly.
All Courses

From novice to tech pro — start learning today.