Jump to content


Photo

Help in checking value patterns


  • Please log in to reply
2 replies to this topic

#1 elioncho

elioncho
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 24 October 2006 - 07:50 PM

Hi. I need to check if a value is written correctly by the user. The value consists of numbers from 1-9 and two decimal places (optional). How can I write a pattern check for this? Thanks...

#2 Caesar

Caesar
  • Members
  • PipPipPip
  • Advanced Member
  • 1,025 posts

Posted 24 October 2006 - 08:11 PM

<?php

$string = $_POST[usr_input];

if(!preg_match('/[0-9]+.?[0-9]+?/',$string)) {

echo'You done messed up, son';
}

else {echo'That\'s the thing there';}

?>

PHP Ninja

#3 elioncho

elioncho
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 25 October 2006 - 12:11 AM

thanks!!! :D thank you very much




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users