This topic is locked
[SOLVED]

 Bad Numeric Validation

4/21/2008 5:15:58 PM
PHPRunner General questions
S
spintz author

I have numeric validation enabled for a field, and when the value 500,000 was entered, it treated the comma as the decimal place identifier. My Language is set to English, and the Regional Setting is English(United States), so ',' sould be just stripped out of the number, and '.' should be used for decimal indicator. I can't find where this is happening...please help, how to stop this?

J
Jane 4/22/2008

Hi,
use Before record added/Before record updated event to change entered value:

if ($values["FieldName"])

{

$values["FieldName"] = str_replace(",","",$values["FieldName"]);

}

S
spintz author 4/22/2008

Thanks Jane. However, my question is more of a concern as to why the regional settings are there if they are not being followed?

J
Jane 4/22/2008

Hi,
regional settings are applied to output only.

PHPRunner does not support to enter numbers with thousand separator on the add/edit pages. All another applications I know work similarly.

S
spintz author 4/22/2008

Could you tell me where PHPR handles this? The database does not do it, and I can't find where PHPR does it. Rather than putting in hacks and doing double work, I'd rather just fix the process to work for my needs.

Alexey admin 4/23/2008

Hi,
sure, the numeric input is processed in add_db_quotes function in include\commonfunction.phpfile

Here is the code:

$strvalue = (string)$value;

$strvalue = str_replace(",",".",$strvalue);

if(is_numeric($strvalue))

$value=$strvalue;

else

$value=0;

S
spintz author 4/23/2008

Fantastic, thank you. This way I can change that code to replace the , with nothing. It would also be great if this was made an option (or even dependent on the Regional Settings).
And to verify, inside that function, the call to 'NeedQuotes' will return true for any kind of text field, correct?

J
Jane 4/23/2008

And to verify, inside that function, the call to 'NeedQuotes' will return true for any kind of text field, correct?



Yes.