Jump to content

Archived

This topic is now archived and is closed to further replies.

elioncho

Help in checking value patterns

Recommended Posts

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...

Share this post


Link to post
Share on other sites
[code]
<?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';}

?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.