Allow only numbers, decimal and major currency symbols

Discussion in 'PHP' started by rsshostedonmyownsite, Jul 12, 2009.

  1. #1
    Hello,

    The following line of code is for an input box that only allows the user to use numbers, decimals or "tba". How can I add to this so that it also allows some of the major currency symbols like the Euro symbol, the pound and $...
    
    if (strtolower($cost) != 'tba') {
    		if (!ereg("^([0-9]+|[0-9]{1,3}(,[0-9]{3})*)(\.[0-9]{1,2})?$", $cost)) {
    			$errors = $errors."Invalid ".$event_name." cost.<br />";
    		}
    	}
    PHP:
     
    rsshostedonmyownsite, Jul 12, 2009 IP
  2. southwind19

    southwind19 Active Member

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    73
    #2
    just add in a square bracket at the start [$, etc ]... i think that should fix it
     
    southwind19, Jul 12, 2009 IP