Hi, I need some help with my form. <form action="stats.php" method="POST"> Username:<br> <input type="text" size="25" class="form" autocomplete="off" maxlength="15" name="buxusername" value="<? echo $row["buxusername"]; ?>"> <br><br> Account balance:<br> $ <input type="text" size="10" class="form" autocomplete="off" maxlength="15" name="balance" value="<? echo $row["balance"]; ?>"> <br><br> Amount of Referrals:<br> <input type="text" size="6" class="form" autocomplete="off" size="5" maxlength="15" name="referrals" value="<? echo $row["referrals"]; ?>"> <br><br> <font color="#9c1515">*</font> Security code:<br> <img src="image.php" onclick="this.src='image.php?newtime=' + (new Date()).getTime();">(Click to reload)<br /> <input type="text" size="5" class="form" autocomplete="off" maxlength="5" name="code"> <br><br> <input type="submit" value="Update"> </form> Code (markup): As you can see I have an input form Account Balance and Amount of Referrals. Well, currently people can submit things like Account Balance: lol Amount of Referals: o_o I want that it only allows numbers in Amount of Referrals e.g. Amount of Referals: 15 Amount of Referals: 15236 and in Account balance some special conditions: e.g. Account Balance: 10 Account Balance: 10.00 Account Balance: 10.000 Account Balance: 10.0000 Can somebody help me with this please? Thanks in advance!!!
You can use functions like: http://uk.php.net/is_int - Referral Amounts http://uk.php.net/manual/en/function.is-numeric.php - Account balance Jay
Ow, I have a problem again. I use this code now to check the input of Account Balance: function isDecimalNumber($n) { return (string)(float)$n === (string)$n; } Code (markup): Now it only allows inputs like: 16.13 or 10, but when I try 16.1325 it doesn't work. This is my piece of code to check if the input is correct: if(isDecimalNumber($balance) == false){ $error = 1; $errormsg .= "<b>Error</b> - Your Account Balance is not correct."; } if($error == 1) { print $errormsg."<br /><br />"; } Code (markup): What's wrong with my code?
Because if I use is_numeric, it won't allow inputs like 10.5025 It needs to allow e.g. '10' or '10.50' or '10.5025' and don't allow e.g. 'lol' or '10.502575' so a maximum of 4 numbers after the point.