Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2006
    Location
    England
    Posts
    610
    Tokens
    0

    Default PHP validation help

    Hi, basically I'm trying to get the PHP to check that $bookPrice (an input field) is either one or two numbers, a dot, then two numbers (13.99 or 3.99). At the moment it checks the correct amount of numbers, but works allows either a . to be entered or not (so it allows 1399).

    Any help would be good
    Thanks
    PHP Code:
    if (preg_match("/^[0-9]{1,2}.[0-9]{2}/"$bookPrice) === 0) {    $error[] = "The price did not contain a decmimal place.";} 
    oh forgot to add, it works if the price is only one number (3.99/399) but not if its (13.99/1399)
    Last edited by PinkFM; 30-11-2011 at 03:53 PM.


  2. #2
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •